
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.electronic_structure.plotter &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script src="../../../_static/jquery.js"></script>
    <script src="../../../_static/underscore.js"></script>
    <script src="../../../_static/doctools.js"></script>
    <script src="../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.electronic_structure.plotter</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.electronic_structure.plotter</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">This module implements plotter for DOS and band structure.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">math</span>
<span class="kn">import</span> <span class="nn">itertools</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">OrderedDict</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">jsanitize</span>
<span class="kn">from</span> <span class="nn">monty.dev</span> <span class="kn">import</span> <span class="n">requires</span>

<span class="k">try</span><span class="p">:</span>
    <span class="kn">from</span> <span class="nn">mayavi</span> <span class="kn">import</span> <span class="n">mlab</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="n">mlab</span> <span class="o">=</span> <span class="kc">None</span>

<span class="kn">from</span> <span class="nn">pymatgen.core.periodic_table</span> <span class="kn">import</span> <span class="n">Element</span>
<span class="kn">from</span> <span class="nn">pymatgen.electronic_structure.core</span> <span class="kn">import</span> <span class="n">Spin</span><span class="p">,</span> <span class="n">OrbitalType</span>
<span class="kn">from</span> <span class="nn">pymatgen.electronic_structure.bandstructure</span> <span class="kn">import</span> <span class="n">BandStructureSymmLine</span>
<span class="kn">from</span> <span class="nn">pymatgen.util.plotting</span> <span class="kn">import</span> <span class="n">pretty_plot</span><span class="p">,</span> \
    <span class="n">add_fig_kwargs</span><span class="p">,</span> <span class="n">get_ax3d_fig_plt</span>
<span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">Counter</span>
<span class="kn">import</span> <span class="nn">copy</span>

<span class="kn">from</span> <span class="nn">pymatgen.electronic_structure.boltztrap</span> <span class="kn">import</span> <span class="n">BoltztrapError</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="s2">&quot;Shyue Ping Ong, Geoffroy Hautier, Anubhav Jain&quot;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s2">&quot;Copyright 2012, The Materials Project&quot;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;0.1&quot;</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s2">&quot;Shyue Ping Ong&quot;</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">&quot;shyuep@gmail.com&quot;</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s2">&quot;May 1, 2012&quot;</span>

<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>


<div class="viewcode-block" id="DosPlotter"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.DosPlotter">[docs]</a><span class="k">class</span> <span class="nc">DosPlotter</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class for plotting DOSs. Note that the interface is extremely flexible</span>
<span class="sd">    given that there are many different ways in which people want to view</span>
<span class="sd">    DOS. The typical usage is::</span>

<span class="sd">        # Initializes plotter with some optional args. Defaults are usually</span>
<span class="sd">        # fine,</span>
<span class="sd">        plotter = DosPlotter()</span>

<span class="sd">        # Adds a DOS with a label.</span>
<span class="sd">        plotter.add_dos(&quot;Total DOS&quot;, dos)</span>

<span class="sd">        # Alternatively, you can add a dict of DOSs. This is the typical</span>
<span class="sd">        # form returned by CompleteDos.get_spd/element/others_dos().</span>
<span class="sd">        plotter.add_dos_dict({&quot;dos1&quot;: dos1, &quot;dos2&quot;: dos2})</span>
<span class="sd">        plotter.add_dos_dict(complete_dos.get_spd_dos())</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zero_at_efermi</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">stack</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">sigma</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            zero_at_efermi: Whether to shift all Dos to have zero energy at the</span>
<span class="sd">                fermi energy. Defaults to True.</span>
<span class="sd">            stack: Whether to plot the DOS as a stacked area graph</span>
<span class="sd">            key_sort_func: function used to sort the dos_dict keys.</span>
<span class="sd">            sigma: A float specifying a standard deviation for Gaussian smearing</span>
<span class="sd">                the DOS for nicer looking plots. Defaults to None for no</span>
<span class="sd">                smearing.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">zero_at_efermi</span> <span class="o">=</span> <span class="n">zero_at_efermi</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">stack</span> <span class="o">=</span> <span class="n">stack</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sigma</span> <span class="o">=</span> <span class="n">sigma</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_doses</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">()</span>

<div class="viewcode-block" id="DosPlotter.add_dos"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.DosPlotter.add_dos">[docs]</a>    <span class="k">def</span> <span class="nf">add_dos</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">dos</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Adds a dos for plotting.</span>

<span class="sd">        Args:</span>
<span class="sd">            label:</span>
<span class="sd">                label for the DOS. Must be unique.</span>
<span class="sd">            dos:</span>
<span class="sd">                Dos object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">energies</span> <span class="o">=</span> <span class="n">dos</span><span class="o">.</span><span class="n">energies</span> <span class="o">-</span> <span class="n">dos</span><span class="o">.</span><span class="n">efermi</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">zero_at_efermi</span> \
            <span class="k">else</span> <span class="n">dos</span><span class="o">.</span><span class="n">energies</span>
        <span class="n">densities</span> <span class="o">=</span> <span class="n">dos</span><span class="o">.</span><span class="n">get_smeared_densities</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sigma</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma</span> \
            <span class="k">else</span> <span class="n">dos</span><span class="o">.</span><span class="n">densities</span>
        <span class="n">efermi</span> <span class="o">=</span> <span class="n">dos</span><span class="o">.</span><span class="n">efermi</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_doses</span><span class="p">[</span><span class="n">label</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;energies&#39;</span><span class="p">:</span> <span class="n">energies</span><span class="p">,</span> <span class="s1">&#39;densities&#39;</span><span class="p">:</span> <span class="n">densities</span><span class="p">,</span>
                              <span class="s1">&#39;efermi&#39;</span><span class="p">:</span> <span class="n">efermi</span><span class="p">}</span></div>

<div class="viewcode-block" id="DosPlotter.add_dos_dict"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.DosPlotter.add_dos_dict">[docs]</a>    <span class="k">def</span> <span class="nf">add_dos_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dos_dict</span><span class="p">,</span> <span class="n">key_sort_func</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Add a dictionary of doses, with an optional sorting function for the</span>
<span class="sd">        keys.</span>

<span class="sd">        Args:</span>
<span class="sd">            dos_dict: dict of {label: Dos}</span>
<span class="sd">            key_sort_func: function used to sort the dos_dict keys.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">key_sort_func</span><span class="p">:</span>
            <span class="n">keys</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">dos_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span> <span class="n">key</span><span class="o">=</span><span class="n">key_sort_func</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">keys</span> <span class="o">=</span> <span class="n">dos_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">label</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">add_dos</span><span class="p">(</span><span class="n">label</span><span class="p">,</span> <span class="n">dos_dict</span><span class="p">[</span><span class="n">label</span><span class="p">])</span></div>

<div class="viewcode-block" id="DosPlotter.get_dos_dict"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.DosPlotter.get_dos_dict">[docs]</a>    <span class="k">def</span> <span class="nf">get_dos_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns the added doses as a json-serializable dict. Note that if you</span>
<span class="sd">        have specified smearing for the DOS plot, the densities returned will</span>
<span class="sd">        be the smeared densities, not the original densities.</span>

<span class="sd">        Returns:</span>
<span class="sd">            dict: Dict of dos data. Generally of the form</span>
<span class="sd">            {label: {&#39;energies&#39;:..., &#39;densities&#39;: {&#39;up&#39;:...}, &#39;efermi&#39;:efermi}}</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">jsanitize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_doses</span><span class="p">)</span></div>

<div class="viewcode-block" id="DosPlotter.get_plot"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.DosPlotter.get_plot">[docs]</a>    <span class="k">def</span> <span class="nf">get_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">xlim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get a matplotlib plot showing the DOS.</span>

<span class="sd">        Args:</span>
<span class="sd">            xlim: Specifies the x-axis limits. Set to None for automatic</span>
<span class="sd">                determination.</span>
<span class="sd">            ylim: Specifies the y-axis limits.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">ncolors</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_doses</span><span class="p">))</span>
        <span class="n">ncolors</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="mi">9</span><span class="p">,</span> <span class="n">ncolors</span><span class="p">)</span>

        <span class="kn">import</span> <span class="nn">palettable</span>

        <span class="n">colors</span> <span class="o">=</span> <span class="n">palettable</span><span class="o">.</span><span class="n">colorbrewer</span><span class="o">.</span><span class="n">qualitative</span><span class="o">.</span><span class="n">Set1_9</span><span class="o">.</span><span class="n">mpl_colors</span>

        <span class="n">y</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">alldensities</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">allenergies</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="n">pretty_plot</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">8</span><span class="p">)</span>

        <span class="c1"># Note that this complicated processing of energies is to allow for</span>
        <span class="c1"># stacked plots in matplotlib.</span>
        <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dos</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_doses</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="n">energies</span> <span class="o">=</span> <span class="n">dos</span><span class="p">[</span><span class="s1">&#39;energies&#39;</span><span class="p">]</span>
            <span class="n">densities</span> <span class="o">=</span> <span class="n">dos</span><span class="p">[</span><span class="s1">&#39;densities&#39;</span><span class="p">]</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">y</span><span class="p">:</span>
                <span class="n">y</span> <span class="o">=</span> <span class="p">{</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">energies</span><span class="o">.</span><span class="n">shape</span><span class="p">),</span>
                     <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">energies</span><span class="o">.</span><span class="n">shape</span><span class="p">)}</span>
            <span class="n">newdens</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">spin</span> <span class="ow">in</span> <span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">,</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]:</span>
                <span class="k">if</span> <span class="n">spin</span> <span class="ow">in</span> <span class="n">densities</span><span class="p">:</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">stack</span><span class="p">:</span>
                        <span class="n">y</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">+=</span> <span class="n">densities</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span>
                        <span class="n">newdens</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">=</span> <span class="n">y</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">newdens</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">=</span> <span class="n">densities</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span>
            <span class="n">allenergies</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">energies</span><span class="p">)</span>
            <span class="n">alldensities</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">newdens</span><span class="p">)</span>

        <span class="n">keys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_doses</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
        <span class="n">keys</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span>
        <span class="n">alldensities</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span>
        <span class="n">allenergies</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span>
        <span class="n">allpts</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">key</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">keys</span><span class="p">):</span>
            <span class="n">x</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">y</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">spin</span> <span class="ow">in</span> <span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">,</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]:</span>
                <span class="k">if</span> <span class="n">spin</span> <span class="ow">in</span> <span class="n">alldensities</span><span class="p">[</span><span class="n">i</span><span class="p">]:</span>
                    <span class="n">densities</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">spin</span><span class="p">)</span> <span class="o">*</span> <span class="n">alldensities</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="n">spin</span><span class="p">])</span>
                    <span class="n">energies</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">allenergies</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                    <span class="k">if</span> <span class="n">spin</span> <span class="o">==</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">:</span>
                        <span class="n">energies</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span>
                        <span class="n">densities</span><span class="o">.</span><span class="n">reverse</span><span class="p">()</span>
                    <span class="n">x</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">energies</span><span class="p">)</span>
                    <span class="n">y</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">densities</span><span class="p">)</span>
            <span class="n">allpts</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)))</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">stack</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">fill</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">i</span> <span class="o">%</span> <span class="n">ncolors</span><span class="p">],</span>
                         <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">key</span><span class="p">))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">i</span> <span class="o">%</span> <span class="n">ncolors</span><span class="p">],</span>
                         <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">key</span><span class="p">),</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">zero_at_efermi</span><span class="p">:</span>
                <span class="n">ylim</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">()</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">_doses</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s1">&#39;efermi&#39;</span><span class="p">],</span>
                          <span class="bp">self</span><span class="o">.</span><span class="n">_doses</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s1">&#39;efermi&#39;</span><span class="p">]],</span> <span class="n">ylim</span><span class="p">,</span>
                         <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">i</span> <span class="o">%</span> <span class="n">ncolors</span><span class="p">],</span>
                         <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">xlim</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="n">xlim</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">ylim</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">ylim</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">xlim</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">()</span>
            <span class="n">relevanty</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">allpts</span>
                         <span class="k">if</span> <span class="n">xlim</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&lt;</span> <span class="n">p</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&lt;</span> <span class="n">xlim</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">((</span><span class="nb">min</span><span class="p">(</span><span class="n">relevanty</span><span class="p">),</span> <span class="nb">max</span><span class="p">(</span><span class="n">relevanty</span><span class="p">)))</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">zero_at_efermi</span><span class="p">:</span>
            <span class="n">ylim</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">ylim</span><span class="p">,</span> <span class="s1">&#39;k--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Energies (eV)&#39;</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s1">&#39;Density of states&#39;</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">axhline</span><span class="p">(</span><span class="n">y</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">()</span>
        <span class="n">leg</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_legend</span><span class="p">()</span>
        <span class="n">ltext</span> <span class="o">=</span> <span class="n">leg</span><span class="o">.</span><span class="n">get_texts</span><span class="p">()</span>  <span class="c1"># all the text.Text instance in the legend</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">setp</span><span class="p">(</span><span class="n">ltext</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="DosPlotter.save_plot"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.DosPlotter.save_plot">[docs]</a>    <span class="k">def</span> <span class="nf">save_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">img_format</span><span class="o">=</span><span class="s2">&quot;eps&quot;</span><span class="p">,</span> <span class="n">xlim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Save matplotlib plot to a file.</span>

<span class="sd">        Args:</span>
<span class="sd">            filename: Filename to write to.</span>
<span class="sd">            img_format: Image format to use. Defaults to EPS.</span>
<span class="sd">            xlim: Specifies the x-axis limits. Set to None for automatic</span>
<span class="sd">                determination.</span>
<span class="sd">            ylim: Specifies the y-axis limits.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_plot</span><span class="p">(</span><span class="n">xlim</span><span class="p">,</span> <span class="n">ylim</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">savefig</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="n">img_format</span><span class="p">)</span></div>

<div class="viewcode-block" id="DosPlotter.show"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.DosPlotter.show">[docs]</a>    <span class="k">def</span> <span class="nf">show</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">xlim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Show the plot using matplotlib.</span>

<span class="sd">        Args:</span>
<span class="sd">            xlim: Specifies the x-axis limits. Set to None for automatic</span>
<span class="sd">                determination.</span>
<span class="sd">            ylim: Specifies the y-axis limits.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_plot</span><span class="p">(</span><span class="n">xlim</span><span class="p">,</span> <span class="n">ylim</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span></div></div>


<div class="viewcode-block" id="BSPlotter"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotter">[docs]</a><span class="k">class</span> <span class="nc">BSPlotter</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class to plot or get data to facilitate the plot of band structure objects.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">bs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            bs: A BandStructureSymmLine object.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bs</span><span class="p">,</span> <span class="n">BandStructureSymmLine</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;BSPlotter only works with BandStructureSymmLine objects. &quot;</span>
                <span class="s2">&quot;A BandStructure object (on a uniform grid for instance and &quot;</span>
                <span class="s2">&quot;not along symmetry lines won&#39;t work)&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span> <span class="o">=</span> <span class="n">bs</span>
        <span class="c1"># TODO: come with an intelligent way to cut the highest unconverged</span>
        <span class="c1"># bands</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">nb_bands</span>

    <span class="k">def</span> <span class="nf">_maketicks</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">plt</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        utility private method to add ticks to a band structure</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">ticks</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_ticks</span><span class="p">()</span>
        <span class="c1"># Sanitize only plot the uniq values</span>
        <span class="n">uniq_d</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">uniq_l</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">temp_ticks</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">],</span> <span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">]))</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_ticks</span><span class="p">)):</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">uniq_d</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">uniq_l</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span>
                <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Adding label </span><span class="si">{l}</span><span class="s2"> at </span><span class="si">{d}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">l</span><span class="o">=</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="n">d</span><span class="o">=</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]:</span>
                    <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Skipping label </span><span class="si">{i}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">i</span><span class="o">=</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Adding label </span><span class="si">{l}</span><span class="s2"> at </span><span class="si">{d}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">l</span><span class="o">=</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="n">d</span><span class="o">=</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
                    <span class="n">uniq_d</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
                    <span class="n">uniq_l</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span>

        <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Unique labels are </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">uniq_d</span><span class="p">,</span> <span class="n">uniq_l</span><span class="p">)))</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">set_xticks</span><span class="p">(</span><span class="n">uniq_d</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">set_xticklabels</span><span class="p">(</span><span class="n">uniq_l</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">])):</span>
            <span class="k">if</span> <span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="c1"># don&#39;t print the same label twice</span>
                <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">==</span> <span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]:</span>
                        <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;already print label... &quot;</span>
                                     <span class="s2">&quot;skipping label </span><span class="si">{i}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="o">=</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]))</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Adding a line at </span><span class="si">{d}</span><span class="s2">&quot;</span>
                                     <span class="s2">&quot; for label </span><span class="si">{l}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">d</span><span class="o">=</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">l</span><span class="o">=</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]))</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">axvline</span><span class="p">(</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Adding a line at </span><span class="si">{d}</span><span class="s2"> for label </span><span class="si">{l}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">d</span><span class="o">=</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">l</span><span class="o">=</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]))</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">axvline</span><span class="p">(</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">plt</span>

<div class="viewcode-block" id="BSPlotter.bs_plot_data"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotter.bs_plot_data">[docs]</a>    <span class="k">def</span> <span class="nf">bs_plot_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zero_to_efermi</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get the data nicely formatted for a plot</span>

<span class="sd">        Args:</span>
<span class="sd">            zero_to_efermi: Automatically subtract off the Fermi energy from the</span>
<span class="sd">                eigenvalues and plot.</span>

<span class="sd">        Returns:</span>
<span class="sd">            dict: A dictionary of the following format:</span>
<span class="sd">            ticks: A dict with the &#39;distances&#39; at which there is a kpoint (the</span>
<span class="sd">            x axis) and the labels (None if no label).</span>
<span class="sd">            energy: A dict storing bands for spin up and spin down data</span>
<span class="sd">            [{Spin:[band_index][k_point_index]}] as a list (one element</span>
<span class="sd">            for each branch) of energy for each kpoint. The data is</span>
<span class="sd">            stored by branch to facilitate the plotting.</span>
<span class="sd">            vbm: A list of tuples (distance,energy) marking the vbms. The</span>
<span class="sd">            energies are shifted with respect to the fermi level is the</span>
<span class="sd">            option has been selected.</span>
<span class="sd">            cbm: A list of tuples (distance,energy) marking the cbms. The</span>
<span class="sd">            energies are shifted with respect to the fermi level is the</span>
<span class="sd">            option has been selected.</span>
<span class="sd">            lattice: The reciprocal lattice.</span>
<span class="sd">            zero_energy: This is the energy used as zero for the plot.</span>
<span class="sd">            band_gap:A string indicating the band gap and its nature (empty if</span>
<span class="sd">            it&#39;s a metal).</span>
<span class="sd">            is_metal: True if the band structure is metallic (i.e., there is at</span>
<span class="sd">            least one band crossing the fermi level).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">distance</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">energy</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="n">zero_energy</span> <span class="o">=</span> <span class="mf">0.0</span>
        <span class="k">if</span> <span class="n">zero_to_efermi</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">():</span>
                <span class="n">zero_energy</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">zero_energy</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">get_vbm</span><span class="p">()[</span><span class="s1">&#39;energy&#39;</span><span class="p">]</span>

        <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">branches</span><span class="p">:</span>

            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                <span class="n">energy</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">):</span> <span class="p">[],</span> <span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">):</span> <span class="p">[]})</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">energy</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">):</span> <span class="p">[]})</span>
            <span class="n">distance</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">distance</span><span class="p">[</span><span class="n">j</span><span class="p">]</span>
                             <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">],</span>
                                            <span class="n">b</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)])</span>
            <span class="n">ticks</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_ticks</span><span class="p">()</span>

            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                <span class="n">energy</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">bands</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">-</span> <span class="n">zero_energy</span>
                     <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">],</span> <span class="n">b</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)])</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                    <span class="n">energy</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                        <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">bands</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">-</span> <span class="n">zero_energy</span>
                         <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">],</span> <span class="n">b</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)])</span>

        <span class="n">vbm</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">get_vbm</span><span class="p">()</span>
        <span class="n">cbm</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">get_cbm</span><span class="p">()</span>

        <span class="n">vbm_plot</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">cbm_plot</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="k">for</span> <span class="n">index</span> <span class="ow">in</span> <span class="n">cbm</span><span class="p">[</span><span class="s1">&#39;kpoint_index&#39;</span><span class="p">]:</span>
            <span class="n">cbm_plot</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">distance</span><span class="p">[</span><span class="n">index</span><span class="p">],</span>
                             <span class="n">cbm</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">zero_energy</span> <span class="k">if</span> <span class="n">zero_to_efermi</span>
                             <span class="k">else</span> <span class="n">cbm</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">]))</span>

        <span class="k">for</span> <span class="n">index</span> <span class="ow">in</span> <span class="n">vbm</span><span class="p">[</span><span class="s1">&#39;kpoint_index&#39;</span><span class="p">]:</span>
            <span class="n">vbm_plot</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">distance</span><span class="p">[</span><span class="n">index</span><span class="p">],</span>
                             <span class="n">vbm</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">zero_energy</span> <span class="k">if</span> <span class="n">zero_to_efermi</span>
                             <span class="k">else</span> <span class="n">vbm</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">]))</span>

        <span class="n">bg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">get_band_gap</span><span class="p">()</span>
        <span class="n">direct</span> <span class="o">=</span> <span class="s2">&quot;Indirect&quot;</span>
        <span class="k">if</span> <span class="n">bg</span><span class="p">[</span><span class="s1">&#39;direct&#39;</span><span class="p">]:</span>
            <span class="n">direct</span> <span class="o">=</span> <span class="s2">&quot;Direct&quot;</span>

        <span class="k">return</span> <span class="p">{</span><span class="s1">&#39;ticks&#39;</span><span class="p">:</span> <span class="n">ticks</span><span class="p">,</span> <span class="s1">&#39;distances&#39;</span><span class="p">:</span> <span class="n">distance</span><span class="p">,</span> <span class="s1">&#39;energy&#39;</span><span class="p">:</span> <span class="n">energy</span><span class="p">,</span>
                <span class="s1">&#39;vbm&#39;</span><span class="p">:</span> <span class="n">vbm_plot</span><span class="p">,</span> <span class="s1">&#39;cbm&#39;</span><span class="p">:</span> <span class="n">cbm_plot</span><span class="p">,</span>
                <span class="s1">&#39;lattice&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">lattice_rec</span><span class="o">.</span><span class="n">as_dict</span><span class="p">(),</span>
                <span class="s1">&#39;zero_energy&#39;</span><span class="p">:</span> <span class="n">zero_energy</span><span class="p">,</span> <span class="s1">&#39;is_metal&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">(),</span>
                <span class="s1">&#39;band_gap&#39;</span><span class="p">:</span> <span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> bandgap = </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">direct</span><span class="p">,</span>
                                                        <span class="n">bg</span><span class="p">[</span><span class="s1">&#39;transition&#39;</span><span class="p">],</span>
                                                        <span class="n">bg</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">])</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">()</span> <span class="k">else</span> <span class="s2">&quot;&quot;</span><span class="p">}</span></div>

<div class="viewcode-block" id="BSPlotter.get_plot"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotter.get_plot">[docs]</a>    <span class="k">def</span> <span class="nf">get_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zero_to_efermi</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">smooth</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                 <span class="n">vbm_cbm_marker</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">smooth_tol</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get a matplotlib object for the bandstructure plot.</span>
<span class="sd">        Blue lines are up spin, red lines are down</span>
<span class="sd">        spin.</span>

<span class="sd">        Args:</span>
<span class="sd">            zero_to_efermi: Automatically subtract off the Fermi energy from</span>
<span class="sd">                the eigenvalues and plot (E-Ef).</span>
<span class="sd">            ylim: Specify the y-axis (energy) limits; by default None let</span>
<span class="sd">                the code choose. It is vbm-4 and cbm+4 if insulator</span>
<span class="sd">                efermi-10 and efermi+10 if metal</span>
<span class="sd">            smooth: interpolates the bands by a spline cubic</span>
<span class="sd">            smooth_tol (float) : tolerance for fitting spline to band data.</span>
<span class="sd">                Default is None such that no tolerance will be used.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="n">pretty_plot</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">8</span><span class="p">)</span>
        <span class="kn">import</span> <span class="nn">scipy.interpolate</span> <span class="k">as</span> <span class="nn">scint</span>

        <span class="c1"># main internal config options</span>
        <span class="n">e_min</span> <span class="o">=</span> <span class="o">-</span><span class="mi">4</span>
        <span class="n">e_max</span> <span class="o">=</span> <span class="mi">4</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">():</span>
            <span class="n">e_min</span> <span class="o">=</span> <span class="o">-</span><span class="mi">10</span>
            <span class="n">e_max</span> <span class="o">=</span> <span class="mi">10</span>
        <span class="c1"># band_linewidth = 3</span>
        <span class="n">band_linewidth</span> <span class="o">=</span> <span class="mi">1</span>

        <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bs_plot_data</span><span class="p">(</span><span class="n">zero_to_efermi</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">smooth</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">])):</span>
                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">],</span>
                             <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
                              <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">]))],</span> <span class="s1">&#39;b-&#39;</span><span class="p">,</span>
                             <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">],</span>
                                 <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
                                  <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">]))],</span>
                                 <span class="s1">&#39;r--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1"># Interpolation failure can be caused by trying to fit an entire</span>
            <span class="c1"># band with one spline rather than fitting with piecewise splines</span>
            <span class="c1"># (splines are ill-suited to fit discontinuities).</span>
            <span class="c1">#</span>
            <span class="c1"># The number of splines used to fit a band is determined by the</span>
            <span class="c1"># number of branches (high symmetry lines) defined in the</span>
            <span class="c1"># BandStructureSymmLine object (see BandStructureSymmLine._branches).</span>

            <span class="n">warning</span> <span class="o">=</span> <span class="s2">&quot;WARNING! Distance / branch </span><span class="si">{d}</span><span class="s2">, band </span><span class="si">{i}</span><span class="s2"> cannot be &quot;</span> <span class="o">+</span> \
                      <span class="s2">&quot;interpolated.</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">+</span> \
                      <span class="s2">&quot;See full warning in source.</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">+</span> \
                      <span class="s2">&quot;If this is not a mistake, try increasing &quot;</span> <span class="o">+</span> \
                      <span class="s2">&quot;smooth_tol.</span><span class="se">\n</span><span class="s2">Current smooth_tol is </span><span class="si">{s}</span><span class="s2">.&quot;</span>

            <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">])):</span>
                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                    <span class="n">tck</span> <span class="o">=</span> <span class="n">scint</span><span class="o">.</span><span class="n">splrep</span><span class="p">(</span>
                        <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">],</span>
                        <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
                         <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">]))],</span>
                        <span class="n">s</span><span class="o">=</span><span class="n">smooth_tol</span><span class="p">)</span>
                    <span class="n">step</span> <span class="o">=</span> <span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
                            <span class="o">-</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span> <span class="o">/</span> <span class="mi">1000</span>

                    <span class="n">xs</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span> <span class="o">*</span> <span class="n">step</span> <span class="o">+</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
                          <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1000</span><span class="p">)]</span>

                    <span class="n">ys</span> <span class="o">=</span> <span class="p">[</span><span class="n">scint</span><span class="o">.</span><span class="n">splev</span><span class="p">(</span><span class="n">x</span> <span class="o">*</span> <span class="n">step</span> <span class="o">+</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span>
                                      <span class="n">tck</span><span class="p">,</span> <span class="n">der</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
                          <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1000</span><span class="p">)]</span>

                    <span class="k">for</span> <span class="n">y</span> <span class="ow">in</span> <span class="n">ys</span><span class="p">:</span>
                        <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">y</span><span class="p">):</span>
                            <span class="nb">print</span><span class="p">(</span><span class="n">warning</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">d</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">d</span><span class="p">),</span> <span class="n">i</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span>
                                                 <span class="n">s</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">smooth_tol</span><span class="p">)))</span>
                            <span class="k">break</span>

                    <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xs</span><span class="p">,</span> <span class="n">ys</span><span class="p">,</span> <span class="s1">&#39;b-&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>

                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                        <span class="n">tck</span> <span class="o">=</span> <span class="n">scint</span><span class="o">.</span><span class="n">splrep</span><span class="p">(</span>
                            <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">],</span>
                            <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
                             <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">]))],</span>
                            <span class="n">s</span><span class="o">=</span><span class="n">smooth_tol</span><span class="p">)</span>
                        <span class="n">step</span> <span class="o">=</span> <span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
                                <span class="o">-</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span> <span class="o">/</span> <span class="mi">1000</span>

                        <span class="n">xs</span> <span class="o">=</span> <span class="p">[</span><span class="n">x</span> <span class="o">*</span> <span class="n">step</span> <span class="o">+</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
                              <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1000</span><span class="p">)]</span>

                        <span class="n">ys</span> <span class="o">=</span> <span class="p">[</span><span class="n">scint</span><span class="o">.</span><span class="n">splev</span><span class="p">(</span>
                            <span class="n">x</span> <span class="o">*</span> <span class="n">step</span> <span class="o">+</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span>
                            <span class="n">tck</span><span class="p">,</span> <span class="n">der</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
                            <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1000</span><span class="p">)]</span>

                        <span class="k">for</span> <span class="n">y</span> <span class="ow">in</span> <span class="n">ys</span><span class="p">:</span>
                            <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">isnan</span><span class="p">(</span><span class="n">y</span><span class="p">):</span>
                                <span class="nb">print</span><span class="p">(</span><span class="n">warning</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">d</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">d</span><span class="p">),</span> <span class="n">i</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">),</span>
                                                     <span class="n">s</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">smooth_tol</span><span class="p">)))</span>
                                <span class="k">break</span>

                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xs</span><span class="p">,</span> <span class="n">ys</span><span class="p">,</span> <span class="s1">&#39;r--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_maketicks</span><span class="p">(</span><span class="n">plt</span><span class="p">)</span>

        <span class="c1"># Main X and Y Labels</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;$\mathrm{Wave\ Vector}$&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="n">ylabel</span> <span class="o">=</span> <span class="sa">r</span><span class="s1">&#39;$\mathrm{E\ -\ E_f\ (eV)}$&#39;</span> <span class="k">if</span> <span class="n">zero_to_efermi</span> \
            <span class="k">else</span> <span class="sa">r</span><span class="s1">&#39;$\mathrm{Energy\ (eV)}$&#39;</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="n">ylabel</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>

        <span class="c1"># Draw Fermi energy, only if not the zero</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">zero_to_efermi</span><span class="p">:</span>
            <span class="n">ef</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">axhline</span><span class="p">(</span><span class="n">ef</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">)</span>

        <span class="c1"># X range (K)</span>
        <span class="c1"># last distance point</span>
        <span class="n">x_max</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">x_max</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">ylim</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">():</span>
                <span class="c1"># Plot A Metal</span>
                <span class="k">if</span> <span class="n">zero_to_efermi</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">e_min</span><span class="p">,</span> <span class="n">e_max</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span> <span class="o">+</span> <span class="n">e_min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span> <span class="o">+</span> <span class="n">e_max</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">vbm_cbm_marker</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">cbm</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;cbm&#39;</span><span class="p">]:</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">cbm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">cbm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;r&#39;</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                    <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
                    <span class="k">for</span> <span class="n">vbm</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;vbm&#39;</span><span class="p">]:</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">vbm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">vbm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                    <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;vbm&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">e_min</span><span class="p">,</span>
                         <span class="n">data</span><span class="p">[</span><span class="s1">&#39;cbm&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">e_max</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">ylim</span><span class="p">)</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">()</span> <span class="ow">and</span> <span class="n">vbm_cbm_marker</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">cbm</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;cbm&#39;</span><span class="p">]:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">cbm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">cbm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;r&#39;</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">vbm</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;vbm&#39;</span><span class="p">]:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">vbm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">vbm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BSPlotter.show"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotter.show">[docs]</a>    <span class="k">def</span> <span class="nf">show</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zero_to_efermi</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">smooth</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
             <span class="n">smooth_tol</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Show the plot using matplotlib.</span>

<span class="sd">        Args:</span>
<span class="sd">            zero_to_efermi: Automatically subtract off the Fermi energy from</span>
<span class="sd">                the eigenvalues and plot (E-Ef).</span>
<span class="sd">            ylim: Specify the y-axis (energy) limits; by default None let</span>
<span class="sd">                the code choose. It is vbm-4 and cbm+4 if insulator</span>
<span class="sd">                efermi-10 and efermi+10 if metal</span>
<span class="sd">            smooth: interpolates the bands by a spline cubic</span>
<span class="sd">            smooth_tol (float) : tolerance for fitting spline to band data.</span>
<span class="sd">                Default is None such that no tolerance will be used.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_plot</span><span class="p">(</span><span class="n">zero_to_efermi</span><span class="p">,</span> <span class="n">ylim</span><span class="p">,</span> <span class="n">smooth</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span></div>

<div class="viewcode-block" id="BSPlotter.save_plot"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotter.save_plot">[docs]</a>    <span class="k">def</span> <span class="nf">save_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">img_format</span><span class="o">=</span><span class="s2">&quot;eps&quot;</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                  <span class="n">zero_to_efermi</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">smooth</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Save matplotlib plot to a file.</span>

<span class="sd">        Args:</span>
<span class="sd">            filename: Filename to write to.</span>
<span class="sd">            img_format: Image format to use. Defaults to EPS.</span>
<span class="sd">            ylim: Specifies the y-axis limits.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_plot</span><span class="p">(</span><span class="n">ylim</span><span class="o">=</span><span class="n">ylim</span><span class="p">,</span> <span class="n">zero_to_efermi</span><span class="o">=</span><span class="n">zero_to_efermi</span><span class="p">,</span>
                            <span class="n">smooth</span><span class="o">=</span><span class="n">smooth</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">savefig</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="n">img_format</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div>

<div class="viewcode-block" id="BSPlotter.get_ticks"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotter.get_ticks">[docs]</a>    <span class="k">def</span> <span class="nf">get_ticks</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get all ticks and labels for a band structure plot.</span>

<span class="sd">        Returns:</span>
<span class="sd">            dict: A dictionary with &#39;distance&#39;: a list of distance at which</span>
<span class="sd">            ticks should be set and &#39;label&#39;: a list of label for each of those</span>
<span class="sd">            ticks.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">tick_distance</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">tick_labels</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">previous_label</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">kpoints</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">label</span>
        <span class="n">previous_branch</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">branches</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="s1">&#39;name&#39;</span><span class="p">]</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">c</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">kpoints</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">label</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">tick_distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">distance</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                <span class="n">this_branch</span> <span class="o">=</span> <span class="kc">None</span>
                <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">branches</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">b</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">]</span> <span class="o">&lt;=</span> <span class="n">i</span> <span class="o">&lt;=</span> <span class="n">b</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]:</span>
                        <span class="n">this_branch</span> <span class="o">=</span> <span class="n">b</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span>
                        <span class="k">break</span>
                <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">label</span> <span class="o">!=</span> <span class="n">previous_label</span> \
                        <span class="ow">and</span> <span class="n">previous_branch</span> <span class="o">!=</span> <span class="n">this_branch</span><span class="p">:</span>
                    <span class="n">label1</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">label</span>
                    <span class="k">if</span> <span class="n">label1</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">label1</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;_&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                        <span class="n">label1</span> <span class="o">=</span> <span class="s2">&quot;$&quot;</span> <span class="o">+</span> <span class="n">label1</span> <span class="o">+</span> <span class="s2">&quot;$&quot;</span>
                    <span class="n">label0</span> <span class="o">=</span> <span class="n">previous_label</span>
                    <span class="k">if</span> <span class="n">label0</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">label0</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;_&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                        <span class="n">label0</span> <span class="o">=</span> <span class="s2">&quot;$&quot;</span> <span class="o">+</span> <span class="n">label0</span> <span class="o">+</span> <span class="s2">&quot;$&quot;</span>
                    <span class="n">tick_labels</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
                    <span class="n">tick_distance</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
                    <span class="n">tick_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">label0</span> <span class="o">+</span> <span class="s2">&quot;$</span><span class="se">\\</span><span class="s2">mid$&quot;</span> <span class="o">+</span> <span class="n">label1</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">c</span><span class="o">.</span><span class="n">label</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">c</span><span class="o">.</span><span class="n">label</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;_&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                        <span class="n">tick_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;$&quot;</span> <span class="o">+</span> <span class="n">c</span><span class="o">.</span><span class="n">label</span> <span class="o">+</span> <span class="s2">&quot;$&quot;</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">tick_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">label</span><span class="p">)</span>
                <span class="n">previous_label</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">label</span>
                <span class="n">previous_branch</span> <span class="o">=</span> <span class="n">this_branch</span>
        <span class="k">return</span> <span class="p">{</span><span class="s1">&#39;distance&#39;</span><span class="p">:</span> <span class="n">tick_distance</span><span class="p">,</span> <span class="s1">&#39;label&#39;</span><span class="p">:</span> <span class="n">tick_labels</span><span class="p">}</span></div>

<div class="viewcode-block" id="BSPlotter.plot_compare"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotter.plot_compare">[docs]</a>    <span class="k">def</span> <span class="nf">plot_compare</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other_plotter</span><span class="p">,</span> <span class="n">legend</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        plot two band structure for comparison. One is in red the other in blue</span>
<span class="sd">        (no difference in spins). The two band structures need to be defined</span>
<span class="sd">        on the same symmetry lines! and the distance between symmetry lines is</span>
<span class="sd">        the one of the band structure used to build the BSPlotter</span>

<span class="sd">        Args:</span>
<span class="sd">            another band structure object defined along the same symmetry lines</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object with both band structures</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># TODO: add exception if the band structures are not compatible</span>
        <span class="kn">import</span> <span class="nn">matplotlib.lines</span> <span class="k">as</span> <span class="nn">mlines</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_plot</span><span class="p">()</span>
        <span class="n">data_orig</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bs_plot_data</span><span class="p">()</span>
        <span class="n">data</span> <span class="o">=</span> <span class="n">other_plotter</span><span class="o">.</span><span class="n">bs_plot_data</span><span class="p">()</span>
        <span class="n">band_linewidth</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">other_plotter</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data_orig</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">])):</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data_orig</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">],</span>
                         <span class="p">[</span><span class="n">e</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">]][</span><span class="n">d</span><span class="p">],</span>
                         <span class="s1">&#39;c-&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">other_plotter</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data_orig</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">d</span><span class="p">],</span>
                             <span class="p">[</span><span class="n">e</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">]][</span><span class="n">d</span><span class="p">],</span>
                             <span class="s1">&#39;m--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">legend</span><span class="p">:</span>
            <span class="n">handles</span> <span class="o">=</span> <span class="p">[</span><span class="n">mlines</span><span class="o">.</span><span class="n">Line2D</span><span class="p">([],</span> <span class="p">[],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
                                     <span class="n">color</span><span class="o">=</span><span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">&#39;bs 1 up&#39;</span><span class="p">),</span>
                       <span class="n">mlines</span><span class="o">.</span><span class="n">Line2D</span><span class="p">([],</span> <span class="p">[],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
                                     <span class="n">color</span><span class="o">=</span><span class="s1">&#39;r&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">&#39;bs 1 down&#39;</span><span class="p">,</span>
                                     <span class="n">linestyle</span><span class="o">=</span><span class="s2">&quot;--&quot;</span><span class="p">),</span>
                       <span class="n">mlines</span><span class="o">.</span><span class="n">Line2D</span><span class="p">([],</span> <span class="p">[],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
                                     <span class="n">color</span><span class="o">=</span><span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">&#39;bs 2 up&#39;</span><span class="p">),</span>
                       <span class="n">mlines</span><span class="o">.</span><span class="n">Line2D</span><span class="p">([],</span> <span class="p">[],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
                                     <span class="n">color</span><span class="o">=</span><span class="s1">&#39;m&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s2">&quot;--&quot;</span><span class="p">,</span>
                                     <span class="n">label</span><span class="o">=</span><span class="s1">&#39;bs 2 down&#39;</span><span class="p">)]</span>

            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">handles</span><span class="o">=</span><span class="n">handles</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BSPlotter.plot_brillouin"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotter.plot_brillouin">[docs]</a>    <span class="k">def</span> <span class="nf">plot_brillouin</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        plot the Brillouin zone</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="c1"># get labels and lines</span>
        <span class="n">labels</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">kpoints</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">k</span><span class="o">.</span><span class="n">label</span><span class="p">:</span>
                <span class="n">labels</span><span class="p">[</span><span class="n">k</span><span class="o">.</span><span class="n">label</span><span class="p">]</span> <span class="o">=</span> <span class="n">k</span><span class="o">.</span><span class="n">frac_coords</span>

        <span class="n">lines</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">branches</span><span class="p">:</span>
            <span class="n">lines</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">kpoints</span><span class="p">[</span><span class="n">b</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">,</span>
                          <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">kpoints</span><span class="p">[</span><span class="n">b</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]]</span><span class="o">.</span><span class="n">frac_coords</span><span class="p">])</span>

        <span class="n">plot_brillouin_zone</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">lattice_rec</span><span class="p">,</span> <span class="n">lines</span><span class="o">=</span><span class="n">lines</span><span class="p">,</span> <span class="n">labels</span><span class="o">=</span><span class="n">labels</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="BSPlotterProjected"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotterProjected">[docs]</a><span class="k">class</span> <span class="nc">BSPlotterProjected</span><span class="p">(</span><span class="n">BSPlotter</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class to plot or get data to facilitate the plot of band structure objects</span>
<span class="sd">    projected along orbitals, elements or sites.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">bs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            bs: A BandStructureSymmLine object with projections.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">bs</span><span class="o">.</span><span class="n">projections</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;try to plot projections&quot;</span>
                             <span class="s2">&quot; on a band structure without any&quot;</span><span class="p">)</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">bs</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_get_projections_by_branches</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dictio</span><span class="p">):</span>
        <span class="n">proj</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">get_projections_on_elements_and_orbitals</span><span class="p">(</span><span class="n">dictio</span><span class="p">)</span>
        <span class="n">proj_br</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">branches</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                <span class="n">proj_br</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="p">{</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">):</span> <span class="p">[[]</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">)],</span>
                     <span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">):</span> <span class="p">[[]</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">)]})</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">proj_br</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="p">{</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">):</span> <span class="p">[[]</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">)]})</span>

            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">],</span> <span class="n">b</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
                    <span class="n">proj_br</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                        <span class="p">{</span><span class="n">e</span><span class="p">:</span> <span class="p">{</span><span class="n">o</span><span class="p">:</span> <span class="n">proj</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="n">e</span><span class="p">][</span><span class="n">o</span><span class="p">]</span>
                             <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">proj</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="n">e</span><span class="p">]}</span>
                         <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">proj</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]})</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">branches</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">],</span> <span class="n">b</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
                            <span class="n">proj_br</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                                <span class="p">{</span><span class="n">e</span><span class="p">:</span> <span class="p">{</span><span class="n">o</span><span class="p">:</span> <span class="n">proj</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="n">e</span><span class="p">][</span><span class="n">o</span><span class="p">]</span>
                                     <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">proj</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="n">e</span><span class="p">]}</span>
                                 <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">proj</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]})</span>
        <span class="k">return</span> <span class="n">proj_br</span>

<div class="viewcode-block" id="BSPlotterProjected.get_projected_plots_dots"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotterProjected.get_projected_plots_dots">[docs]</a>    <span class="k">def</span> <span class="nf">get_projected_plots_dots</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dictio</span><span class="p">,</span> <span class="n">zero_to_efermi</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                                 <span class="n">vbm_cbm_marker</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Method returning a plot composed of subplots along different elements</span>
<span class="sd">        and orbitals.</span>

<span class="sd">        Args:</span>
<span class="sd">            dictio: The element and orbitals you want a projection on. The</span>
<span class="sd">                format is {Element:[Orbitals]} for instance</span>
<span class="sd">                {&#39;Cu&#39;:[&#39;d&#39;,&#39;s&#39;],&#39;O&#39;:[&#39;p&#39;]} will give projections for Cu on</span>
<span class="sd">                d and s orbitals and on oxygen p.</span>
<span class="sd">                If you use this class to plot LobsterBandStructureSymmLine,</span>
<span class="sd">                the orbitals are named as in the FATBAND filename, e.g.</span>
<span class="sd">                &quot;2p&quot; or &quot;2p_x&quot;</span>

<span class="sd">        Returns:</span>
<span class="sd">            a pylab object with different subfigures for each projection</span>
<span class="sd">            The blue and red colors are for spin up and spin down.</span>
<span class="sd">            The bigger the red or blue dot in the band structure the higher</span>
<span class="sd">            character for the corresponding element and orbital.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">band_linewidth</span> <span class="o">=</span> <span class="mf">1.0</span>
        <span class="n">fig_number</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">([</span><span class="nb">len</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">dictio</span><span class="o">.</span><span class="n">values</span><span class="p">()])</span>
        <span class="n">proj</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_projections_by_branches</span><span class="p">(</span><span class="n">dictio</span><span class="p">)</span>
        <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bs_plot_data</span><span class="p">(</span><span class="n">zero_to_efermi</span><span class="p">)</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="n">pretty_plot</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">8</span><span class="p">)</span>
        <span class="n">e_min</span> <span class="o">=</span> <span class="o">-</span><span class="mi">4</span>
        <span class="n">e_max</span> <span class="o">=</span> <span class="mi">4</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">():</span>
            <span class="n">e_min</span> <span class="o">=</span> <span class="o">-</span><span class="mi">10</span>
            <span class="n">e_max</span> <span class="o">=</span> <span class="mi">10</span>
        <span class="n">count</span> <span class="o">=</span> <span class="mi">1</span>

        <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">el</span><span class="p">]:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">100</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">ceil</span><span class="p">(</span><span class="n">fig_number</span> <span class="o">/</span> <span class="mi">2</span><span class="p">)</span> <span class="o">+</span> <span class="mi">20</span> <span class="o">+</span> <span class="n">count</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_maketicks</span><span class="p">(</span><span class="n">plt</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">])):</span>
                    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">],</span>
                                 <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
                                  <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">]))],</span>
                                 <span class="s1">&#39;b-&#39;</span><span class="p">,</span>
                                 <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>
                        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">],</span>
                                     <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
                                      <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span>
                                      <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">]))],</span>
                                     <span class="s1">&#39;r--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>
                            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span>
                                    <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">])):</span>
                                <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="n">j</span><span class="p">],</span>
                                         <span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">],</span> <span class="s1">&#39;ro&#39;</span><span class="p">,</span>
                                         <span class="n">markersize</span><span class="o">=</span><span class="n">proj</span><span class="p">[</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)][</span><span class="n">o</span><span class="p">]</span> <span class="o">*</span> <span class="mf">15.0</span><span class="p">)</span>
                        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">])):</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="n">j</span><span class="p">],</span>
                                     <span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">],</span>
                                     <span class="s1">&#39;bo&#39;</span><span class="p">,</span>
                                     <span class="n">markersize</span><span class="o">=</span><span class="n">proj</span><span class="p">[</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)][</span><span class="n">o</span><span class="p">]</span> <span class="o">*</span> <span class="mf">15.0</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">ylim</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">():</span>
                        <span class="k">if</span> <span class="n">zero_to_efermi</span><span class="p">:</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">e_min</span><span class="p">,</span> <span class="n">e_max</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span> <span class="o">+</span> <span class="n">e_min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span>
                                     <span class="o">+</span> <span class="n">e_max</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">if</span> <span class="n">vbm_cbm_marker</span><span class="p">:</span>
                            <span class="k">for</span> <span class="n">cbm</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;cbm&#39;</span><span class="p">]:</span>
                                <span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">cbm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">cbm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;r&#39;</span><span class="p">,</span>
                                            <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                            <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>

                            <span class="k">for</span> <span class="n">vbm</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;vbm&#39;</span><span class="p">]:</span>
                                <span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">vbm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">vbm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;g&#39;</span><span class="p">,</span>
                                            <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                            <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>

                        <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;vbm&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">e_min</span><span class="p">,</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;cbm&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>
                                 <span class="o">+</span> <span class="n">e_max</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">ylim</span><span class="p">)</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">o</span><span class="p">))</span>
                <span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BSPlotterProjected.get_elt_projected_plots"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotterProjected.get_elt_projected_plots">[docs]</a>    <span class="k">def</span> <span class="nf">get_elt_projected_plots</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zero_to_efermi</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                                <span class="n">vbm_cbm_marker</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Method returning a plot composed of subplots along different elements</span>

<span class="sd">        Returns:</span>
<span class="sd">            a pylab object with different subfigures for each projection</span>
<span class="sd">            The blue and red colors are for spin up and spin down</span>
<span class="sd">            The bigger the red or blue dot in the band structure the higher</span>
<span class="sd">            character for the corresponding element and orbital</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">band_linewidth</span> <span class="o">=</span> <span class="mf">1.0</span>
        <span class="n">proj</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_projections_by_branches</span><span class="p">({</span><span class="n">e</span><span class="o">.</span><span class="n">symbol</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">]</span>
                                                  <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span>
                                                  <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">elements</span><span class="p">})</span>
        <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bs_plot_data</span><span class="p">(</span><span class="n">zero_to_efermi</span><span class="p">)</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="n">pretty_plot</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">8</span><span class="p">)</span>
        <span class="n">e_min</span> <span class="o">=</span> <span class="o">-</span><span class="mi">4</span>
        <span class="n">e_max</span> <span class="o">=</span> <span class="mi">4</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">():</span>
            <span class="n">e_min</span> <span class="o">=</span> <span class="o">-</span><span class="mi">10</span>
            <span class="n">e_max</span> <span class="o">=</span> <span class="mi">10</span>
        <span class="n">count</span> <span class="o">=</span> <span class="mi">1</span>
        <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">elements</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">220</span> <span class="o">+</span> <span class="n">count</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_maketicks</span><span class="p">(</span><span class="n">plt</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">])):</span>
                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">],</span>
                             <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
                              <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">]))],</span> <span class="s1">&#39;-&#39;</span><span class="p">,</span>
                             <span class="n">color</span><span class="o">=</span><span class="p">[</span><span class="mi">192</span> <span class="o">/</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">192</span> <span class="o">/</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">192</span> <span class="o">/</span> <span class="mi">255</span><span class="p">],</span>
                             <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">],</span>
                                 <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
                                  <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">]))],</span>
                                 <span class="s1">&#39;--&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="p">[</span><span class="mi">128</span> <span class="o">/</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">128</span> <span class="o">/</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">128</span> <span class="o">/</span> <span class="mi">255</span><span class="p">],</span>
                                 <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>
                        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">])):</span>
                            <span class="n">markerscale</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">([</span><span class="n">proj</span><span class="p">[</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span>
                                                   <span class="n">j</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)][</span><span class="n">o</span><span class="p">]</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span>
                                               <span class="n">proj</span><span class="p">[</span><span class="n">b</span><span class="p">]</span>
                                               <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span>
                                                   <span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)]])</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="n">j</span><span class="p">],</span>
                                     <span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">],</span>
                                     <span class="s1">&#39;bo&#39;</span><span class="p">,</span>
                                     <span class="n">markersize</span><span class="o">=</span><span class="n">markerscale</span> <span class="o">*</span> <span class="mf">15.0</span><span class="p">,</span>
                                     <span class="n">color</span><span class="o">=</span><span class="p">[</span><span class="n">markerscale</span><span class="p">,</span> <span class="mf">0.3</span> <span class="o">*</span> <span class="n">markerscale</span><span class="p">,</span>
                                            <span class="mf">0.4</span> <span class="o">*</span> <span class="n">markerscale</span><span class="p">])</span>
                    <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">])):</span>
                        <span class="n">markerscale</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span>
                            <span class="p">[</span><span class="n">proj</span><span class="p">[</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)][</span><span class="n">o</span><span class="p">]</span>
                             <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">proj</span><span class="p">[</span><span class="n">b</span><span class="p">]</span>
                             <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)]])</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="n">j</span><span class="p">],</span>
                                 <span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">],</span> <span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                 <span class="n">markersize</span><span class="o">=</span><span class="n">markerscale</span> <span class="o">*</span> <span class="mf">15.0</span><span class="p">,</span>
                                 <span class="n">color</span><span class="o">=</span><span class="p">[</span><span class="n">markerscale</span><span class="p">,</span> <span class="mf">0.3</span> <span class="o">*</span> <span class="n">markerscale</span><span class="p">,</span>
                                        <span class="mf">0.4</span> <span class="o">*</span> <span class="n">markerscale</span><span class="p">])</span>
            <span class="k">if</span> <span class="n">ylim</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">():</span>
                    <span class="k">if</span> <span class="n">zero_to_efermi</span><span class="p">:</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">e_min</span><span class="p">,</span> <span class="n">e_max</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span> <span class="o">+</span> <span class="n">e_min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span>
                                 <span class="o">+</span> <span class="n">e_max</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">vbm_cbm_marker</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">cbm</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;cbm&#39;</span><span class="p">]:</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">cbm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">cbm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;r&#39;</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                        <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>

                        <span class="k">for</span> <span class="n">vbm</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;vbm&#39;</span><span class="p">]:</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">vbm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">vbm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                        <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>

                    <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;vbm&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">e_min</span><span class="p">,</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;cbm&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>
                             <span class="o">+</span> <span class="n">e_max</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">ylim</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">))</span>
            <span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>

        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BSPlotterProjected.get_elt_projected_plots_color"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotterProjected.get_elt_projected_plots_color">[docs]</a>    <span class="k">def</span> <span class="nf">get_elt_projected_plots_color</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zero_to_efermi</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                                      <span class="n">elt_ordered</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        returns a pylab plot object with one plot where the band structure</span>
<span class="sd">        line color depends on the character of the band (along different</span>
<span class="sd">        elements). Each element is associated with red, green or blue</span>
<span class="sd">        and the corresponding rgb color depending on the character of the band</span>
<span class="sd">        is used. The method can only deal with binary and ternary compounds</span>

<span class="sd">        spin up and spin down are differientiated by a &#39;-&#39; and a &#39;--&#39; line</span>

<span class="sd">        Args:</span>
<span class="sd">            elt_ordered: A list of Element ordered. The first one is red,</span>
<span class="sd">                second green, last blue</span>

<span class="sd">        Returns:</span>
<span class="sd">            a pylab object</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">band_linewidth</span> <span class="o">=</span> <span class="mf">3.0</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">elements</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">3</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span>
        <span class="k">if</span> <span class="n">elt_ordered</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">elt_ordered</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">elements</span>
        <span class="n">proj</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_projections_by_branches</span><span class="p">(</span>
            <span class="p">{</span><span class="n">e</span><span class="o">.</span><span class="n">symbol</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">]</span>
             <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">elements</span><span class="p">})</span>
        <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bs_plot_data</span><span class="p">(</span><span class="n">zero_to_efermi</span><span class="p">)</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="n">pretty_plot</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">8</span><span class="p">)</span>

        <span class="n">spins</span> <span class="o">=</span> <span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
            <span class="n">spins</span> <span class="o">=</span> <span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">,</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_maketicks</span><span class="p">(</span><span class="n">plt</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">spins</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">])):</span>
                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                    <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">s</span><span class="p">)][</span><span class="n">i</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span><span class="p">):</span>
                        <span class="n">sum_e</span> <span class="o">=</span> <span class="mf">0.0</span>
                        <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">elt_ordered</span><span class="p">:</span>
                            <span class="n">sum_e</span> <span class="o">=</span> <span class="n">sum_e</span> <span class="o">+</span> \
                                    <span class="nb">sum</span><span class="p">([</span><span class="n">proj</span><span class="p">[</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">s</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)][</span><span class="n">o</span><span class="p">]</span>
                                         <span class="k">for</span> <span class="n">o</span>
                                         <span class="ow">in</span> <span class="n">proj</span><span class="p">[</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">s</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)]])</span>
                        <span class="k">if</span> <span class="n">sum_e</span> <span class="o">==</span> <span class="mf">0.0</span><span class="p">:</span>
                            <span class="n">color</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.0</span><span class="p">]</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">elt_ordered</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">color</span> <span class="o">=</span> <span class="p">[</span><span class="nb">sum</span><span class="p">([</span><span class="n">proj</span><span class="p">[</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">s</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)][</span><span class="n">o</span><span class="p">]</span>
                                          <span class="k">for</span> <span class="n">o</span>
                                          <span class="ow">in</span> <span class="n">proj</span><span class="p">[</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">s</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">el</span><span class="p">)]])</span>
                                     <span class="o">/</span> <span class="n">sum_e</span>
                                     <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">elt_ordered</span><span class="p">]</span>
                        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">color</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                            <span class="n">color</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.0</span><span class="p">)</span>
                            <span class="n">color</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">color</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                            <span class="n">color</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.0</span>
                        <span class="n">sign</span> <span class="o">=</span> <span class="s1">&#39;-&#39;</span>
                        <span class="k">if</span> <span class="n">s</span> <span class="o">==</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">:</span>
                            <span class="n">sign</span> <span class="o">=</span> <span class="s1">&#39;--&#39;</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="n">j</span><span class="p">],</span>
                                  <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="n">j</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]],</span>
                                 <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">s</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">],</span>
                                  <span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">s</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]],</span> <span class="n">sign</span><span class="p">,</span>
                                 <span class="n">color</span><span class="o">=</span><span class="n">color</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">zero_to_efermi</span><span class="p">:</span>
                <span class="n">e_min</span> <span class="o">=</span> <span class="o">-</span><span class="mi">10</span>
                <span class="n">e_max</span> <span class="o">=</span> <span class="mi">10</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">e_min</span><span class="p">,</span> <span class="n">e_max</span><span class="p">)</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span> <span class="o">+</span> <span class="n">e_min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span> <span class="o">+</span> <span class="n">e_max</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;vbm&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="mf">4.0</span><span class="p">,</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;cbm&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mf">2.0</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">plt</span></div>

    <span class="k">def</span> <span class="nf">_get_projections_by_branches_patom_pmorb</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dictio</span><span class="p">,</span> <span class="n">dictpa</span><span class="p">,</span>
                                                 <span class="n">sum_atoms</span><span class="p">,</span> <span class="n">sum_morbs</span><span class="p">,</span>
                                                 <span class="n">selected_branches</span><span class="p">):</span>
        <span class="kn">import</span> <span class="nn">copy</span>
        <span class="n">setos</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;s&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;py&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;pz&#39;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s1">&#39;px&#39;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span> <span class="s1">&#39;dxy&#39;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span> <span class="s1">&#39;dyz&#39;</span><span class="p">:</span> <span class="mi">5</span><span class="p">,</span>
                 <span class="s1">&#39;dz2&#39;</span><span class="p">:</span> <span class="mi">6</span><span class="p">,</span> <span class="s1">&#39;dxz&#39;</span><span class="p">:</span> <span class="mi">7</span><span class="p">,</span>
                 <span class="s1">&#39;dx2&#39;</span><span class="p">:</span> <span class="mi">8</span><span class="p">,</span> <span class="s1">&#39;f_3&#39;</span><span class="p">:</span> <span class="mi">9</span><span class="p">,</span> <span class="s1">&#39;f_2&#39;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span> <span class="s1">&#39;f_1&#39;</span><span class="p">:</span> <span class="mi">11</span><span class="p">,</span> <span class="s1">&#39;f0&#39;</span><span class="p">:</span> <span class="mi">12</span><span class="p">,</span> <span class="s1">&#39;f1&#39;</span><span class="p">:</span> <span class="mi">13</span><span class="p">,</span>
                 <span class="s1">&#39;f2&#39;</span><span class="p">:</span> <span class="mi">14</span><span class="p">,</span> <span class="s1">&#39;f3&#39;</span><span class="p">:</span> <span class="mi">15</span><span class="p">}</span>

        <span class="n">num_branches</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">branches</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">selected_branches</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">indices</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">selected_branches</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
                <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
                    <span class="s2">&quot;You do not give a correct type of &#39;selected_branches&#39;. It should be &#39;list&#39; type.&quot;</span><span class="p">)</span>
            <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">selected_branches</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;The &#39;selected_branches&#39; is empty. We cannot do anything.&quot;</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">index</span> <span class="ow">in</span> <span class="n">selected_branches</span><span class="p">:</span>
                    <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">index</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                            <span class="s2">&quot;You do not give a correct type of index of symmetry lines. It should be &quot;</span>
                            <span class="s2">&quot;&#39;int&#39; type&quot;</span><span class="p">)</span>
                    <span class="k">elif</span> <span class="n">index</span> <span class="o">&gt;</span> <span class="n">num_branches</span> <span class="ow">or</span> <span class="n">index</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                            <span class="s2">&quot;You give a incorrect index of symmetry lines: </span><span class="si">%s</span><span class="s2">. The index should be in &quot;</span>
                            <span class="s2">&quot;range of [1, </span><span class="si">%s</span><span class="s2">].&quot;</span> <span class="o">%</span> <span class="p">(</span>
                                <span class="nb">str</span><span class="p">(</span><span class="n">index</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">num_branches</span><span class="p">)))</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">indices</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">indices</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">num_branches</span><span class="p">)</span>

        <span class="n">proj</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">projections</span>
        <span class="n">proj_br</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">index</span> <span class="ow">in</span> <span class="n">indices</span><span class="p">:</span>
            <span class="n">b</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">branches</span><span class="p">[</span><span class="n">index</span><span class="p">]</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">b</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                <span class="n">proj_br</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="p">{</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">):</span> <span class="p">[[]</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">)],</span>
                     <span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">):</span> <span class="p">[[]</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">)]})</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">proj_br</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="p">{</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">):</span> <span class="p">[[]</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">)]})</span>

            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">],</span> <span class="n">b</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
                    <span class="n">edict</span> <span class="o">=</span> <span class="p">{}</span>
                    <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)]</span> <span class="o">=</span> <span class="p">{}</span>
                            <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> \
                                    <span class="n">proj</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="n">setos</span><span class="p">[</span><span class="n">morb</span><span class="p">]][</span><span class="n">anum</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
                    <span class="n">proj_br</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">edict</span><span class="p">)</span>

            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                    <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">b</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">],</span> <span class="n">b</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
                        <span class="n">edict</span> <span class="o">=</span> <span class="p">{}</span>
                        <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                            <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)]</span> <span class="o">=</span> <span class="p">{}</span>
                                <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                    <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> \
                                        <span class="n">proj</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="n">setos</span><span class="p">[</span><span class="n">morb</span><span class="p">]][</span><span class="n">anum</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
                        <span class="n">proj_br</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">edict</span><span class="p">)</span>

        <span class="c1"># Adjusting  projections for plot</span>
        <span class="n">dictio_d</span><span class="p">,</span> <span class="n">dictpa_d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_summarize_keys_for_plot</span><span class="p">(</span><span class="n">dictio</span><span class="p">,</span> <span class="n">dictpa</span><span class="p">,</span>
                                                           <span class="n">sum_atoms</span><span class="p">,</span> <span class="n">sum_morbs</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;dictio_d: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">dictio_d</span><span class="p">))</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;dictpa_d: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">dictpa_d</span><span class="p">))</span>

        <span class="k">if</span> <span class="p">(</span><span class="n">sum_atoms</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">sum_morbs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">):</span>
            <span class="n">proj_br_d</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">proj_br</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">proj_br_d</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">branch</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
            <span class="k">for</span> <span class="n">index</span> <span class="ow">in</span> <span class="n">indices</span><span class="p">:</span>
                <span class="n">branch</span> <span class="o">+=</span> <span class="mi">1</span>
                <span class="n">br</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">branches</span><span class="p">[</span><span class="n">index</span><span class="p">]</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                    <span class="n">proj_br_d</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                        <span class="p">{</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">):</span> <span class="p">[[]</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">)],</span>
                         <span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">):</span> <span class="p">[[]</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">)]})</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">proj_br_d</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                        <span class="p">{</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">):</span> <span class="p">[[]</span> <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">)]})</span>

                <span class="k">if</span> <span class="p">(</span><span class="n">sum_atoms</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">sum_morbs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">):</span>
                    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">br</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">br</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
                            <span class="n">atoms_morbs</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                <span class="n">proj_br</span><span class="p">[</span><span class="n">branch</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">])</span>
                            <span class="n">edict</span> <span class="o">=</span> <span class="p">{}</span>
                            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                                <span class="k">if</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">:</span>
                                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                            <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">])</span>
                                    <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span>
                                    <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                        <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">sprojection</span> <span class="o">+=</span> \
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)][</span><span class="n">morb</span><span class="p">]</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span>
                                            <span class="n">morb</span><span class="p">]</span> <span class="o">=</span> <span class="n">sprojection</span>
                                <span class="k">else</span><span class="p">:</span>
                                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                            <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">])</span>
                            <span class="n">proj_br_d</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">edict</span><span class="p">)</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">br</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">br</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
                                <span class="n">atoms_morbs</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                    <span class="n">proj_br</span><span class="p">[</span><span class="n">branch</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">])</span>
                                <span class="n">edict</span> <span class="o">=</span> <span class="p">{}</span>
                                <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                                    <span class="k">if</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">:</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">])</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                            <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                                <span class="n">sprojection</span> <span class="o">+=</span> \
                                                    <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)][</span>
                                                        <span class="n">morb</span><span class="p">]</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span>
                                                <span class="n">morb</span><span class="p">]</span> <span class="o">=</span> <span class="n">sprojection</span>
                                    <span class="k">else</span><span class="p">:</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">])</span>
                                <span class="n">proj_br_d</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">edict</span><span class="p">)</span>

                <span class="k">elif</span> <span class="p">(</span><span class="n">sum_atoms</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">sum_morbs</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">):</span>
                    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">br</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">br</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
                            <span class="n">atoms_morbs</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                <span class="n">proj_br</span><span class="p">[</span><span class="n">branch</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">])</span>
                            <span class="n">edict</span> <span class="o">=</span> <span class="p">{}</span>
                            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                                <span class="k">if</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">:</span>
                                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> \
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                        <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">sprojection</span> <span class="o">+=</span> \
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span>
                                            <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">sprojection</span>
                                <span class="k">else</span><span class="p">:</span>
                                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                            <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">])</span>
                            <span class="n">proj_br_d</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">edict</span><span class="p">)</span>
                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">br</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">br</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
                                <span class="n">atoms_morbs</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                    <span class="n">proj_br</span><span class="p">[</span><span class="n">branch</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">])</span>
                                <span class="n">edict</span> <span class="o">=</span> <span class="p">{}</span>
                                <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                                    <span class="k">if</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">:</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                                            <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                                <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                            <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                            <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                                <span class="n">sprojection</span> <span class="o">+=</span> <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span>
                                                <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">sprojection</span>
                                    <span class="k">else</span><span class="p">:</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">])</span>
                                <span class="n">proj_br_d</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">edict</span><span class="p">)</span>

                <span class="k">else</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">br</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">br</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
                            <span class="n">atoms_morbs</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                <span class="n">proj_br</span><span class="p">[</span><span class="n">branch</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">])</span>
                            <span class="n">edict</span> <span class="o">=</span> <span class="p">{}</span>
                            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                                <span class="k">if</span> <span class="p">(</span><span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">):</span>
                                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> \
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                        <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">sprojection</span> <span class="o">+=</span> \
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span>
                                            <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">sprojection</span>

                                    <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span>
                                    <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                        <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">sprojection</span> <span class="o">+=</span> \
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)][</span><span class="n">morb</span><span class="p">]</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span>
                                            <span class="n">morb</span><span class="p">]</span> <span class="o">=</span> <span class="n">sprojection</span>

                                    <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">sprojection</span> <span class="o">+=</span> \
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)][</span><span class="n">morb</span><span class="p">]</span>
                                    <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span>
                                        <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">sprojection</span>

                                <span class="k">elif</span> <span class="p">(</span><span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span>
                                        <span class="n">elt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">):</span>
                                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                            <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">])</span>
                                    <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span>
                                    <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                        <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">sprojection</span> <span class="o">+=</span> \
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)][</span><span class="n">morb</span><span class="p">]</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span>
                                            <span class="n">morb</span><span class="p">]</span> <span class="o">=</span> <span class="n">sprojection</span>

                                <span class="k">elif</span> <span class="p">(</span><span class="n">elt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span>
                                        <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">):</span>
                                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                        <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">sprojection</span> <span class="o">+=</span> <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span>
                                            <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">sprojection</span>

                                <span class="k">else</span><span class="p">:</span>
                                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                            <span class="n">proj_br_d</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">edict</span><span class="p">)</span>

                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">br</span><span class="p">[</span><span class="s1">&#39;end_index&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">br</span><span class="p">[</span><span class="s1">&#39;start_index&#39;</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
                                <span class="n">atoms_morbs</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">proj_br</span><span class="p">[</span><span class="n">branch</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">])</span>
                                <span class="n">edict</span> <span class="o">=</span> <span class="p">{}</span>
                                <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                                    <span class="k">if</span> <span class="p">(</span><span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span>
                                            <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">):</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                                            <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                                <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                            <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                            <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                                <span class="n">sprojection</span> <span class="o">+=</span> <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">sprojection</span>

                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                            <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                            <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                                <span class="n">sprojection</span> <span class="o">+=</span> <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)][</span><span class="n">morb</span><span class="p">]</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> <span class="n">sprojection</span>

                                        <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                                <span class="n">sprojection</span> <span class="o">+=</span> \
                                                    <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)][</span>
                                                        <span class="n">morb</span><span class="p">]</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span>
                                            <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">sprojection</span>

                                    <span class="k">elif</span> <span class="p">(</span><span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span>
                                            <span class="n">elt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">):</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span>
                                                <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">])</span>
                                        <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span>
                                        <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                            <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                                <span class="n">sprojection</span> <span class="o">+=</span> \
                                                    <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)][</span>
                                                        <span class="n">morb</span><span class="p">]</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]][</span>
                                                <span class="n">morb</span><span class="p">]</span> <span class="o">=</span> <span class="n">sprojection</span>

                                    <span class="k">elif</span> <span class="p">(</span><span class="n">elt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span>
                                            <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">):</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                                            <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
                                                <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> \
                                                    <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                            <span class="n">sprojection</span> <span class="o">=</span> <span class="mf">0.0</span>
                                            <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                                <span class="n">sprojection</span> <span class="o">+=</span> \
                                                    <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span>
                                                <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span> <span class="o">=</span> <span class="n">sprojection</span>

                                    <span class="k">else</span><span class="p">:</span>
                                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                            <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                                            <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                                <span class="n">edict</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span> <span class="o">=</span> \
                                                    <span class="n">atoms_morbs</span><span class="p">[</span><span class="n">elt</span> <span class="o">+</span> <span class="n">anum</span><span class="p">][</span><span class="n">morb</span><span class="p">]</span>
                                <span class="n">proj_br_d</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">edict</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">proj_br_d</span><span class="p">,</span> <span class="n">dictio_d</span><span class="p">,</span> <span class="n">dictpa_d</span><span class="p">,</span> <span class="n">indices</span>

<div class="viewcode-block" id="BSPlotterProjected.get_projected_plots_dots_patom_pmorb"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSPlotterProjected.get_projected_plots_dots_patom_pmorb">[docs]</a>    <span class="k">def</span> <span class="nf">get_projected_plots_dots_patom_pmorb</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dictio</span><span class="p">,</span> <span class="n">dictpa</span><span class="p">,</span>
                                             <span class="n">sum_atoms</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">sum_morbs</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                                             <span class="n">zero_to_efermi</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                                             <span class="n">vbm_cbm_marker</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                                             <span class="n">selected_branches</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                                             <span class="n">w_h_size</span><span class="o">=</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">8</span><span class="p">),</span> <span class="n">num_column</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Method returns a plot composed of subplots for different atoms and</span>
<span class="sd">        orbitals (subshell orbitals such as &#39;s&#39;, &#39;p&#39;, &#39;d&#39; and &#39;f&#39; defined by</span>
<span class="sd">        azimuthal quantum numbers l = 0, 1, 2 and 3, respectively or</span>
<span class="sd">        individual orbitals like &#39;px&#39;, &#39;py&#39; and &#39;pz&#39; defined by magnetic</span>
<span class="sd">        quantum numbers m = -1, 1 and 0, respectively).</span>
<span class="sd">        This is an extension of &quot;get_projected_plots_dots&quot; method.</span>

<span class="sd">        Args:</span>
<span class="sd">            dictio: The elements and the orbitals you need to project on. The</span>
<span class="sd">                format is {Element:[Orbitals]}, for instance:</span>
<span class="sd">                {&#39;Cu&#39;:[&#39;dxy&#39;,&#39;s&#39;,&#39;px&#39;],&#39;O&#39;:[&#39;px&#39;,&#39;py&#39;,&#39;pz&#39;]} will give</span>
<span class="sd">                projections for Cu on orbitals dxy, s, px and</span>
<span class="sd">                for O on orbitals px, py, pz. If you want to sum over all</span>
<span class="sd">                individual orbitals of subshell orbitals,</span>
<span class="sd">                for example, &#39;px&#39;, &#39;py&#39; and &#39;pz&#39; of O, just simply set</span>
<span class="sd">                {&#39;Cu&#39;:[&#39;dxy&#39;,&#39;s&#39;,&#39;px&#39;],&#39;O&#39;:[&#39;p&#39;]} and set sum_morbs (see</span>
<span class="sd">                explanations below) as {&#39;O&#39;:[p],...}.</span>
<span class="sd">                Otherwise, you will get an error.</span>
<span class="sd">            dictpa: The elements and their sites (defined by site numbers) you</span>
<span class="sd">                need to project on. The format is</span>
<span class="sd">                {Element: [Site numbers]}, for instance: {&#39;Cu&#39;:[1,5],&#39;O&#39;:[3,4]}</span>
<span class="sd">                will give projections for Cu on site-1</span>
<span class="sd">                and on site-5, O on site-3 and on site-4 in the cell.</span>
<span class="sd">                Attention:</span>
<span class="sd">                The correct site numbers of atoms are consistent with</span>
<span class="sd">                themselves in the structure computed. Normally,</span>
<span class="sd">                the structure should be totally similar with POSCAR file,</span>
<span class="sd">                however, sometimes VASP can rotate or</span>
<span class="sd">                translate the cell. Thus, it would be safe if using Vasprun</span>
<span class="sd">                class to get the final_structure and as a</span>
<span class="sd">                result, correct index numbers of atoms.</span>
<span class="sd">            sum_atoms: Sum projection of the similar atoms together (e.g.: Cu</span>
<span class="sd">                on site-1 and Cu on site-5). The format is</span>
<span class="sd">                {Element: [Site numbers]}, for instance:</span>
<span class="sd">                 {&#39;Cu&#39;: [1,5], &#39;O&#39;: [3,4]} means summing projections over Cu on</span>
<span class="sd">                 site-1 and Cu on site-5 and O on site-3</span>
<span class="sd">                 and on site-4. If you do not want to use this functional, just</span>
<span class="sd">                 turn it off by setting sum_atoms = None.</span>
<span class="sd">            sum_morbs: Sum projections of individual orbitals of similar atoms</span>
<span class="sd">                together (e.g.: &#39;dxy&#39; and &#39;dxz&#39;). The</span>
<span class="sd">                format is {Element: [individual orbitals]}, for instance:</span>
<span class="sd">                {&#39;Cu&#39;: [&#39;dxy&#39;, &#39;dxz&#39;], &#39;O&#39;: [&#39;px&#39;, &#39;py&#39;]} means summing</span>
<span class="sd">                projections over &#39;dxy&#39; and &#39;dxz&#39; of Cu and &#39;px&#39;</span>
<span class="sd">                and &#39;py&#39; of O. If you do not want to use this functional, just</span>
<span class="sd">                turn it off by setting sum_morbs = None.</span>
<span class="sd">            selected_branches: The index of symmetry lines you chose for</span>
<span class="sd">                plotting. This can be useful when the number of</span>
<span class="sd">                symmetry lines (in KPOINTS file) are manny while you only want</span>
<span class="sd">                to show for certain ones. The format is</span>
<span class="sd">                [index of line], for instance:</span>
<span class="sd">                [1, 3, 4] means you just need to do projection along lines</span>
<span class="sd">                number 1, 3 and 4 while neglecting lines</span>
<span class="sd">                number 2 and so on. By default, this is None type and all</span>
<span class="sd">                symmetry lines will be plotted.</span>
<span class="sd">            w_h_size: This variable help you to control the width and height</span>
<span class="sd">                of figure. By default, width = 12 and</span>
<span class="sd">                height = 8 (inches). The width/height ratio is kept the same</span>
<span class="sd">                for subfigures and the size of each depends</span>
<span class="sd">                on how many number of subfigures are plotted.</span>
<span class="sd">            num_column: This variable help you to manage how the subfigures are</span>
<span class="sd">                arranged in the figure by setting</span>
<span class="sd">                up the number of columns of subfigures. The value should be an</span>
<span class="sd">                int number. For example, num_column = 3</span>
<span class="sd">                means you want to plot subfigures in 3 columns. By default,</span>
<span class="sd">                num_column = None and subfigures are</span>
<span class="sd">                aligned in 2 columns.</span>

<span class="sd">        Returns:</span>
<span class="sd">            A pylab object with different subfigures for different projections.</span>
<span class="sd">            The blue and red colors lines are bands</span>
<span class="sd">            for spin up and spin down. The green and cyan dots are projections</span>
<span class="sd">            for spin up and spin down. The bigger</span>
<span class="sd">            the green or cyan dots in the projected band structures, the higher</span>
<span class="sd">            character for the corresponding elements</span>
<span class="sd">            and orbitals. List of individual orbitals and their numbers (set up</span>
<span class="sd">            by VASP and no special meaning):</span>
<span class="sd">            s = 0; py = 1 pz = 2 px = 3; dxy = 4 dyz = 5 dz2 = 6 dxz = 7 dx2 = 8;</span>
<span class="sd">            f_3 = 9 f_2 = 10 f_1 = 11 f0 = 12 f1 = 13 f2 = 14 f3 = 15</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">dictio</span><span class="p">,</span> <span class="n">sum_morbs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Orbitals_SumOrbitals</span><span class="p">(</span><span class="n">dictio</span><span class="p">,</span> <span class="n">sum_morbs</span><span class="p">)</span>
        <span class="n">dictpa</span><span class="p">,</span> <span class="n">sum_atoms</span><span class="p">,</span> <span class="n">number_figs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_number_of_subfigures</span><span class="p">(</span><span class="n">dictio</span><span class="p">,</span> <span class="n">dictpa</span><span class="p">,</span> <span class="n">sum_atoms</span><span class="p">,</span> <span class="n">sum_morbs</span><span class="p">)</span>
        <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Number of subfigures: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">number_figs</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">number_figs</span> <span class="o">&gt;</span> <span class="mi">9</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span>
                <span class="s2">&quot;The number of sub-figures </span><span class="si">%s</span><span class="s2"> might be too manny and the implementation might take a long time.</span><span class="se">\n</span><span class="s2">&quot;</span>
                <span class="s2">&quot;A smaller number or a plot with selected symmetry lines (selected_branches) might be better.</span><span class="se">\n</span><span class="s2">&quot;</span>
                <span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">number_figs</span><span class="p">))</span>
        <span class="kn">from</span> <span class="nn">pymatgen.util.plotting</span> <span class="kn">import</span> <span class="n">pretty_plot</span>
        <span class="n">band_linewidth</span> <span class="o">=</span> <span class="mf">0.5</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="n">pretty_plot</span><span class="p">(</span><span class="n">w_h_size</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">w_h_size</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
        <span class="n">proj_br_d</span><span class="p">,</span> <span class="n">dictio_d</span><span class="p">,</span> <span class="n">dictpa_d</span><span class="p">,</span> <span class="n">branches</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_projections_by_branches_patom_pmorb</span><span class="p">(</span>
            <span class="n">dictio</span><span class="p">,</span> <span class="n">dictpa</span><span class="p">,</span>
            <span class="n">sum_atoms</span><span class="p">,</span> <span class="n">sum_morbs</span><span class="p">,</span> <span class="n">selected_branches</span><span class="p">)</span>
        <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bs_plot_data</span><span class="p">(</span><span class="n">zero_to_efermi</span><span class="p">)</span>
        <span class="n">e_min</span> <span class="o">=</span> <span class="o">-</span><span class="mi">4</span>
        <span class="n">e_max</span> <span class="o">=</span> <span class="mi">4</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">():</span>
            <span class="n">e_min</span> <span class="o">=</span> <span class="o">-</span><span class="mi">10</span>
            <span class="n">e_max</span> <span class="o">=</span> <span class="mi">10</span>

        <span class="n">count</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">numa</span> <span class="ow">in</span> <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>

                    <span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
                    <span class="k">if</span> <span class="n">num_column</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                        <span class="k">if</span> <span class="n">number_figs</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">row</span> <span class="o">=</span> <span class="n">number_figs</span> <span class="o">/</span> <span class="mi">2</span>
                            <span class="k">if</span> <span class="n">number_figs</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                                <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">count</span><span class="p">)</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">row</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">count</span><span class="p">)</span>
                    <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">num_column</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
                        <span class="n">row</span> <span class="o">=</span> <span class="n">number_figs</span> <span class="o">/</span> <span class="n">num_column</span>
                        <span class="k">if</span> <span class="n">number_figs</span> <span class="o">%</span> <span class="n">num_column</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">num_column</span><span class="p">,</span> <span class="n">count</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">row</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">num_column</span><span class="p">,</span> <span class="n">count</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                            <span class="s2">&quot;The invalid &#39;num_column&#39; is assigned. It should be an integer.&quot;</span><span class="p">)</span>

                    <span class="n">plt</span><span class="p">,</span> <span class="n">shift</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_maketicks_selected</span><span class="p">(</span><span class="n">plt</span><span class="p">,</span> <span class="n">branches</span><span class="p">)</span>
                    <span class="n">br</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
                    <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="n">branches</span><span class="p">:</span>
                        <span class="n">br</span> <span class="o">+=</span> <span class="mi">1</span>
                        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_nb_bands</span><span class="p">):</span>
                            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span> <span class="o">-</span> <span class="n">shift</span><span class="p">[</span><span class="n">br</span><span class="p">],</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">])),</span>
                                     <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">]</span>
                                      <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span>
                                      <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">]))],</span>
                                     <span class="s1">&#39;b-&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>

                            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                                <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span> <span class="o">-</span> <span class="n">shift</span><span class="p">[</span><span class="n">br</span><span class="p">],</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">])),</span>
                                         <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span>
                                              <span class="n">j</span><span class="p">]</span>
                                          <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span>
                                          <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">]))],</span>
                                         <span class="s1">&#39;r--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="n">band_linewidth</span><span class="p">)</span>
                                <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span>
                                        <span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">])):</span>
                                    <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span>
                                        <span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">-</span> <span class="n">shift</span><span class="p">[</span><span class="n">br</span><span class="p">],</span>
                                        <span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">],</span>
                                        <span class="s1">&#39;co&#39;</span><span class="p">,</span> <span class="n">markersize</span><span class="o">=</span><span class="n">proj_br_d</span><span class="p">[</span><span class="n">br</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="n">elt</span> <span class="o">+</span> <span class="n">numa</span><span class="p">][</span><span class="n">o</span><span class="p">]</span> <span class="o">*</span> <span class="mf">15.0</span><span class="p">)</span>

                            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">])):</span>
                                <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;distances&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="n">j</span><span class="p">]</span> <span class="o">-</span> <span class="n">shift</span><span class="p">[</span><span class="n">br</span><span class="p">],</span>
                                         <span class="n">data</span><span class="p">[</span><span class="s1">&#39;energy&#39;</span><span class="p">][</span><span class="n">b</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">],</span>
                                         <span class="s1">&#39;go&#39;</span><span class="p">,</span> <span class="n">markersize</span><span class="o">=</span><span class="n">proj_br_d</span><span class="p">[</span><span class="n">br</span><span class="p">][</span><span class="nb">str</span><span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">)][</span><span class="n">i</span><span class="p">][</span><span class="n">j</span><span class="p">][</span><span class="n">elt</span> <span class="o">+</span> <span class="n">numa</span><span class="p">][</span><span class="n">o</span><span class="p">]</span> <span class="o">*</span> <span class="mf">15.0</span><span class="p">)</span>

                    <span class="k">if</span> <span class="n">ylim</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">is_metal</span><span class="p">():</span>
                            <span class="k">if</span> <span class="n">zero_to_efermi</span><span class="p">:</span>
                                <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">e_min</span><span class="p">,</span> <span class="n">e_max</span><span class="p">)</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">efermi</span> <span class="o">+</span> <span class="n">e_min</span><span class="p">,</span>
                                         <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">_efermi</span>
                                         <span class="o">+</span> <span class="n">e_max</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="k">if</span> <span class="n">vbm_cbm_marker</span><span class="p">:</span>
                                <span class="k">for</span> <span class="n">cbm</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;cbm&#39;</span><span class="p">]:</span>
                                    <span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">cbm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">cbm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;r&#39;</span><span class="p">,</span>
                                                <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                                <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>

                                <span class="k">for</span> <span class="n">vbm</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s1">&#39;vbm&#39;</span><span class="p">]:</span>
                                    <span class="n">plt</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">vbm</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">vbm</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;g&#39;</span><span class="p">,</span>
                                                <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;o&#39;</span><span class="p">,</span>
                                                <span class="n">s</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span>

                            <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="s1">&#39;vbm&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">e_min</span><span class="p">,</span>
                                     <span class="n">data</span><span class="p">[</span><span class="s1">&#39;cbm&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span>
                                     <span class="o">+</span> <span class="n">e_max</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">ylim</span><span class="p">)</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">elt</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="n">numa</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">o</span><span class="p">))</span>

        <span class="k">return</span> <span class="n">plt</span></div>

    <span class="k">def</span> <span class="nf">_Orbitals_SumOrbitals</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dictio</span><span class="p">,</span> <span class="n">sum_morbs</span><span class="p">):</span>
        <span class="n">all_orbitals</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">,</span> <span class="s1">&#39;d&#39;</span><span class="p">,</span> <span class="s1">&#39;f&#39;</span><span class="p">,</span> <span class="s1">&#39;px&#39;</span><span class="p">,</span> <span class="s1">&#39;py&#39;</span><span class="p">,</span> <span class="s1">&#39;pz&#39;</span><span class="p">,</span> <span class="s1">&#39;dxy&#39;</span><span class="p">,</span> <span class="s1">&#39;dyz&#39;</span><span class="p">,</span>
                        <span class="s1">&#39;dxz&#39;</span><span class="p">,</span> <span class="s1">&#39;dx2&#39;</span><span class="p">,</span> <span class="s1">&#39;dz2&#39;</span><span class="p">,</span>
                        <span class="s1">&#39;f_3&#39;</span><span class="p">,</span> <span class="s1">&#39;f_2&#39;</span><span class="p">,</span> <span class="s1">&#39;f_1&#39;</span><span class="p">,</span> <span class="s1">&#39;f0&#39;</span><span class="p">,</span> <span class="s1">&#39;f1&#39;</span><span class="p">,</span> <span class="s1">&#39;f2&#39;</span><span class="p">,</span> <span class="s1">&#39;f3&#39;</span><span class="p">]</span>
        <span class="n">individual_orbs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;p&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;px&#39;</span><span class="p">,</span> <span class="s1">&#39;py&#39;</span><span class="p">,</span> <span class="s1">&#39;pz&#39;</span><span class="p">],</span>
                           <span class="s1">&#39;d&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;dxy&#39;</span><span class="p">,</span> <span class="s1">&#39;dyz&#39;</span><span class="p">,</span> <span class="s1">&#39;dxz&#39;</span><span class="p">,</span> <span class="s1">&#39;dx2&#39;</span><span class="p">,</span> <span class="s1">&#39;dz2&#39;</span><span class="p">],</span>
                           <span class="s1">&#39;f&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;f_3&#39;</span><span class="p">,</span> <span class="s1">&#39;f_2&#39;</span><span class="p">,</span> <span class="s1">&#39;f_1&#39;</span><span class="p">,</span> <span class="s1">&#39;f0&#39;</span><span class="p">,</span> <span class="s1">&#39;f1&#39;</span><span class="p">,</span> <span class="s1">&#39;f2&#39;</span><span class="p">,</span> <span class="s1">&#39;f3&#39;</span><span class="p">]}</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dictio</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
                <span class="s2">&quot;The invalid type of &#39;dictio&#39; was bound. It should be dict type.&quot;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictio</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="s2">&quot;The &#39;dictio&#39; is empty. We cannot do anything.&quot;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">Element</span><span class="o">.</span><span class="n">is_valid_symbol</span><span class="p">(</span><span class="n">elt</span><span class="p">):</span>
                    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">],</span> <span class="nb">list</span><span class="p">):</span>
                        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;The dictio[</span><span class="si">%s</span><span class="s2">] is empty. We cannot do anything&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                        <span class="k">for</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">orb</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
                                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                    <span class="s2">&quot;The invalid format of orbitals is in &#39;dictio[</span><span class="si">%s</span><span class="s2">]&#39;: </span><span class="si">%s</span><span class="s2">. &quot;</span>
                                    <span class="s2">&quot;They should be string.&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">elt</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">orb</span><span class="p">)))</span>
                            <span class="k">elif</span> <span class="n">orb</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">all_orbitals</span><span class="p">:</span>
                                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                    <span class="s2">&quot;The invalid name of orbital is given in &#39;dictio[</span><span class="si">%s</span><span class="s2">]&#39;.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="k">if</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">individual_orbs</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span>
                                            <span class="n">individual_orbs</span><span class="p">[</span><span class="n">orb</span><span class="p">]))</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
                                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                            <span class="s2">&quot;The &#39;dictio[</span><span class="si">%s</span><span class="s2">]&#39; contains orbitals repeated.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                        <span class="n">nelems</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span><span class="o">.</span><span class="n">values</span><span class="p">()</span>
                        <span class="k">if</span> <span class="nb">sum</span><span class="p">(</span><span class="n">nelems</span><span class="p">)</span> <span class="o">&gt;</span> <span class="nb">len</span><span class="p">(</span><span class="n">nelems</span><span class="p">):</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;You put in at least two similar orbitals in dictio[</span><span class="si">%s</span><span class="s2">].&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
                            <span class="s2">&quot;The invalid type of value was put into &#39;dictio[</span><span class="si">%s</span><span class="s2">]&#39;. It should be list &quot;</span>
                            <span class="s2">&quot;type.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span>
                        <span class="s2">&quot;The invalid element was put into &#39;dictio&#39; as a key: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">sum_morbs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;You do not want to sum projection over orbitals.&quot;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
                <span class="s2">&quot;The invalid type of &#39;sum_orbs&#39; was bound. It should be dict or &#39;None&#39; type.&quot;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">sum_morbs</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="s2">&quot;The &#39;sum_morbs&#39; is empty. We cannot do anything&quot;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">Element</span><span class="o">.</span><span class="n">is_valid_symbol</span><span class="p">(</span><span class="n">elt</span><span class="p">):</span>
                    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">],</span> <span class="nb">list</span><span class="p">):</span>
                        <span class="k">for</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">orb</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
                                <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
                                    <span class="s2">&quot;The invalid format of orbitals is in &#39;sum_morbs[</span><span class="si">%s</span><span class="s2">]&#39;: </span><span class="si">%s</span><span class="s2">. &quot;</span>
                                    <span class="s2">&quot;They should be string.&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">elt</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">orb</span><span class="p">)))</span>
                            <span class="k">elif</span> <span class="n">orb</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">all_orbitals</span><span class="p">:</span>
                                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                    <span class="s2">&quot;The invalid name of orbital in &#39;sum_morbs[</span><span class="si">%s</span><span class="s2">]&#39; is given.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="k">if</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">individual_orbs</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span>
                                            <span class="n">individual_orbs</span><span class="p">[</span><span class="n">orb</span><span class="p">]))</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
                                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                            <span class="s2">&quot;The &#39;sum_morbs[</span><span class="si">%s</span><span class="s2">]&#39; contains orbitals repeated.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                        <span class="n">nelems</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span><span class="o">.</span><span class="n">values</span><span class="p">()</span>
                        <span class="k">if</span> <span class="nb">sum</span><span class="p">(</span><span class="n">nelems</span><span class="p">)</span> <span class="o">&gt;</span> <span class="nb">len</span><span class="p">(</span><span class="n">nelems</span><span class="p">):</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;You put in at least two similar orbitals in sum_morbs[</span><span class="si">%s</span><span class="s2">].&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
                            <span class="s2">&quot;The invalid type of value was put into &#39;sum_morbs[</span><span class="si">%s</span><span class="s2">]&#39;. It should be list &quot;</span>
                            <span class="s2">&quot;type.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">elt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">dictio</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                            <span class="s2">&quot;You cannot sum projection over orbitals of atoms &#39;</span><span class="si">%s</span><span class="s2">&#39; because they are not &quot;</span>
                            <span class="s2">&quot;mentioned in &#39;dictio&#39;.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span>
                        <span class="s2">&quot;The invalid element was put into &#39;sum_morbs&#39; as a key: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                            <span class="s2">&quot;You cannot sum projection over one individual orbital &#39;</span><span class="si">%s</span><span class="s2">&#39; of &#39;</span><span class="si">%s</span><span class="s2">&#39;.&quot;</span> <span class="o">%</span>
                            <span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="n">elt</span><span class="p">))</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">sum_morbs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                        <span class="k">pass</span>
                    <span class="k">elif</span> <span class="n">elt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                        <span class="nb">print</span><span class="p">(</span>
                            <span class="s2">&quot;You do not want to sum projection over orbitals of element: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;The empty list is an invalid value for sum_morbs[</span><span class="si">%s</span><span class="s2">].&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                            <span class="k">for</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                <span class="k">if</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">orb</span><span class="p">:</span>
                                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                        <span class="s2">&quot;The invalid orbital &#39;</span><span class="si">%s</span><span class="s2">&#39; was put into &#39;sum_morbs[</span><span class="si">%s</span><span class="s2">]&#39;.&quot;</span> <span class="o">%</span>
                                        <span class="p">(</span><span class="n">orb</span><span class="p">,</span> <span class="n">elt</span><span class="p">))</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="k">if</span> <span class="n">orb</span> <span class="o">==</span> <span class="s1">&#39;s&#39;</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">orb</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                    <span class="s2">&quot;The invalid orbital &#39;</span><span class="si">%s</span><span class="s2">&#39; was put into sum_orbs[&#39;</span><span class="si">%s</span><span class="s2">&#39;].&quot;</span> <span class="o">%</span> <span class="p">(</span>
                                        <span class="n">orb</span><span class="p">,</span> <span class="n">elt</span><span class="p">))</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="n">individual_orbs</span><span class="p">[</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="mi">0</span><span class="p">]]</span>
                                <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="n">individual_orbs</span><span class="p">[</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="mi">0</span><span class="p">]]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">duplicate</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>
                <span class="k">for</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                    <span class="k">if</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">individual_orbs</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                        <span class="n">duplicate</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">orb</span><span class="p">)</span>
                        <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">individual_orbs</span><span class="p">[</span><span class="n">orb</span><span class="p">]:</span>
                            <span class="n">duplicate</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">o</span><span class="p">)</span>
                <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">duplicate</span><span class="p">)</span>

                <span class="k">if</span> <span class="n">sum_morbs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                    <span class="k">pass</span>
                <span class="k">elif</span> <span class="n">elt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                    <span class="nb">print</span><span class="p">(</span>
                        <span class="s2">&quot;You do not want to sum projection over orbitals of element: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                            <span class="s2">&quot;The empty list is an invalid value for sum_morbs[</span><span class="si">%s</span><span class="s2">].&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                    <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                        <span class="n">orb</span> <span class="o">=</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
                        <span class="k">if</span> <span class="n">orb</span> <span class="o">==</span> <span class="s1">&#39;s&#39;</span><span class="p">:</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;We do not sum projection over only &#39;s&#39; orbital of the same &quot;</span>
                                <span class="s2">&quot;type of element.&quot;</span><span class="p">)</span>
                        <span class="k">elif</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">individual_orbs</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                            <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
                            <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">individual_orbs</span><span class="p">[</span><span class="n">orb</span><span class="p">]:</span>
                                <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">o</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;You never sum projection over one orbital in sum_morbs[</span><span class="si">%s</span><span class="s2">]&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">duplicate</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>
                        <span class="k">for</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="k">if</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">individual_orbs</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                                <span class="n">duplicate</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">orb</span><span class="p">)</span>
                                <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">individual_orbs</span><span class="p">[</span><span class="n">orb</span><span class="p">]:</span>
                                    <span class="n">duplicate</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">o</span><span class="p">)</span>
                        <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">deepcopy</span><span class="p">(</span><span class="n">duplicate</span><span class="p">)</span>

                    <span class="k">for</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                        <span class="k">if</span> <span class="n">orb</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;The orbitals of sum_morbs[</span><span class="si">%s</span><span class="s2">] conflict with those of dictio[</span><span class="si">%s</span><span class="s2">].&quot;</span> <span class="o">%</span>
                                <span class="p">(</span><span class="n">elt</span><span class="p">,</span> <span class="n">elt</span><span class="p">))</span>

        <span class="k">return</span> <span class="n">dictio</span><span class="p">,</span> <span class="n">sum_morbs</span>

    <span class="k">def</span> <span class="nf">_number_of_subfigures</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dictio</span><span class="p">,</span> <span class="n">dictpa</span><span class="p">,</span> <span class="n">sum_atoms</span><span class="p">,</span> <span class="n">sum_morbs</span><span class="p">):</span>
        <span class="kn">from</span> <span class="nn">pymatgen.core.periodic_table</span> <span class="kn">import</span> <span class="n">Element</span>
        <span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">Counter</span>

        <span class="k">if</span> <span class="p">(</span><span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dictpa</span><span class="p">,</span> <span class="nb">dict</span><span class="p">)):</span>
            <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
                <span class="s2">&quot;The invalid type of &#39;dictpa&#39; was bound. It should be dict type.&quot;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictpa</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="s2">&quot;The &#39;dictpa&#39; is empty. We cannot do anything.&quot;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">Element</span><span class="o">.</span><span class="n">is_valid_symbol</span><span class="p">(</span><span class="n">elt</span><span class="p">):</span>
                    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">],</span> <span class="nb">list</span><span class="p">):</span>
                        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;The dictpa[</span><span class="si">%s</span><span class="s2">] is empty. We cannot do anything&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                        <span class="n">_sites</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">sites</span>
                        <span class="n">indices</span> <span class="o">=</span> <span class="p">[]</span>
                        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">_sites</span><span class="p">)):</span>
                            <span class="k">if</span> <span class="nb">list</span><span class="p">(</span><span class="n">_sites</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">_species</span><span class="o">.</span><span class="n">keys</span><span class="p">())[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="fm">__eq__</span><span class="p">(</span>
                                    <span class="n">Element</span><span class="p">(</span><span class="n">elt</span><span class="p">)):</span>
                                <span class="n">indices</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
                        <span class="k">for</span> <span class="n">number</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">number</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
                                <span class="k">if</span> <span class="s1">&#39;all&#39;</span> <span class="o">==</span> <span class="n">number</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
                                    <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="n">indices</span>
                                    <span class="nb">print</span><span class="p">(</span>
                                        <span class="s2">&quot;You want to consider all &#39;</span><span class="si">%s</span><span class="s2">&#39; atoms.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                                    <span class="k">break</span>
                                <span class="k">else</span><span class="p">:</span>
                                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                        <span class="s2">&quot;You put wrong site numbers in &#39;dictpa[</span><span class="si">%s</span><span class="s2">]&#39;: </span><span class="si">%s</span><span class="s2">.&quot;</span> <span class="o">%</span>
                                        <span class="p">(</span><span class="n">elt</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">number</span><span class="p">)))</span>
                            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">number</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
                                <span class="k">if</span> <span class="n">number</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">indices</span><span class="p">:</span>
                                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                        <span class="s2">&quot;You put wrong site numbers in &#39;dictpa[</span><span class="si">%s</span><span class="s2">]&#39;: </span><span class="si">%s</span><span class="s2">.&quot;</span> <span class="o">%</span>
                                        <span class="p">(</span><span class="n">elt</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">number</span><span class="p">)))</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                    <span class="s2">&quot;You put wrong site numbers in &#39;dictpa[</span><span class="si">%s</span><span class="s2">]&#39;: </span><span class="si">%s</span><span class="s2">.&quot;</span> <span class="o">%</span> <span class="p">(</span>
                                        <span class="n">elt</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">number</span><span class="p">)))</span>
                        <span class="n">nelems</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">(</span><span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span><span class="o">.</span><span class="n">values</span><span class="p">()</span>
                        <span class="k">if</span> <span class="nb">sum</span><span class="p">(</span><span class="n">nelems</span><span class="p">)</span> <span class="o">&gt;</span> <span class="nb">len</span><span class="p">(</span><span class="n">nelems</span><span class="p">):</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;You put at least two similar site numbers into &#39;dictpa[</span><span class="si">%s</span><span class="s2">]&#39;.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
                            <span class="s2">&quot;The invalid type of value was put into &#39;dictpa[</span><span class="si">%s</span><span class="s2">]&#39;. It should be list &quot;</span>
                            <span class="s2">&quot;type.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span>
                        <span class="s2">&quot;The invalid element was put into &#39;dictpa&#39; as a key: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">dictio</span><span class="o">.</span><span class="n">keys</span><span class="p">()))</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">dictpa</span><span class="o">.</span><span class="n">keys</span><span class="p">())):</span>
            <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span>
                <span class="s2">&quot;The number of keys in &#39;dictio&#39; and &#39;dictpa&#39; are not the same.&quot;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictio</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                <span class="k">if</span> <span class="n">elt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                    <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="s2">&quot;The element &#39;</span><span class="si">%s</span><span class="s2">&#39; is not in both dictpa and dictio.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                <span class="k">if</span> <span class="n">elt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">dictio</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                    <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="s2">&quot;The element &#39;</span><span class="si">%s</span><span class="s2">&#39; in not in both dictpa and dictio.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">sum_atoms</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;You do not want to sum projection over atoms.&quot;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s2">&quot;The invalid type of &#39;sum_atoms&#39; was bound. It should be dict type.&quot;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">sum_atoms</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span><span class="s2">&quot;The &#39;sum_atoms&#39; is empty. We cannot do anything.&quot;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">Element</span><span class="o">.</span><span class="n">is_valid_symbol</span><span class="p">(</span><span class="n">elt</span><span class="p">):</span>
                    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">],</span> <span class="nb">list</span><span class="p">):</span>
                        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;The sum_atoms[</span><span class="si">%s</span><span class="s2">] is empty. We cannot do anything&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                        <span class="n">_sites</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">sites</span>
                        <span class="n">indices</span> <span class="o">=</span> <span class="p">[]</span>
                        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">_sites</span><span class="p">)):</span>
                            <span class="k">if</span> <span class="nb">list</span><span class="p">(</span><span class="n">_sites</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">_species</span><span class="o">.</span><span class="n">keys</span><span class="p">())[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="fm">__eq__</span><span class="p">(</span>
                                    <span class="n">Element</span><span class="p">(</span><span class="n">elt</span><span class="p">)):</span>
                                <span class="n">indices</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
                        <span class="k">for</span> <span class="n">number</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">number</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
                                <span class="k">if</span> <span class="s1">&#39;all&#39;</span> <span class="o">==</span> <span class="n">number</span><span class="o">.</span><span class="n">lower</span><span class="p">():</span>
                                    <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="n">indices</span>
                                    <span class="nb">print</span><span class="p">(</span>
                                        <span class="s2">&quot;You want to sum projection over all &#39;</span><span class="si">%s</span><span class="s2">&#39; atoms.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                                    <span class="k">break</span>
                                <span class="k">else</span><span class="p">:</span>
                                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                        <span class="s2">&quot;You put wrong site numbers in &#39;sum_atoms[</span><span class="si">%s</span><span class="s2">]&#39;.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">number</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
                                <span class="k">if</span> <span class="n">number</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">indices</span><span class="p">:</span>
                                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                        <span class="s2">&quot;You put wrong site numbers in &#39;sum_atoms[</span><span class="si">%s</span><span class="s2">]&#39;.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                                <span class="k">elif</span> <span class="n">number</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                        <span class="s2">&quot;You cannot sum projection with atom number &#39;</span><span class="si">%s</span><span class="s2">&#39; because it is not &quot;</span>
                                        <span class="s2">&quot;metioned in dicpta[</span><span class="si">%s</span><span class="s2">]&quot;</span> <span class="o">%</span> <span class="p">(</span>
                                            <span class="nb">str</span><span class="p">(</span><span class="n">number</span><span class="p">),</span> <span class="n">elt</span><span class="p">))</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                    <span class="s2">&quot;You put wrong site numbers in &#39;sum_atoms[</span><span class="si">%s</span><span class="s2">]&#39;.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                        <span class="n">nelems</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span><span class="o">.</span><span class="n">values</span><span class="p">()</span>
                        <span class="k">if</span> <span class="nb">sum</span><span class="p">(</span><span class="n">nelems</span><span class="p">)</span> <span class="o">&gt;</span> <span class="nb">len</span><span class="p">(</span><span class="n">nelems</span><span class="p">):</span>
                            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                                <span class="s2">&quot;You put at least two similar site numbers into &#39;sum_atoms[</span><span class="si">%s</span><span class="s2">]&#39;.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span>
                            <span class="s2">&quot;The invalid type of value was put into &#39;sum_atoms[</span><span class="si">%s</span><span class="s2">]&#39;. It should be list &quot;</span>
                            <span class="s2">&quot;type.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">elt</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                            <span class="s2">&quot;You cannot sum projection over atoms &#39;</span><span class="si">%s</span><span class="s2">&#39; because it is not &quot;</span>
                            <span class="s2">&quot;mentioned in &#39;dictio&#39;.&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">raise</span> <span class="ne">KeyError</span><span class="p">(</span>
                        <span class="s2">&quot;The invalid element was put into &#39;sum_atoms&#39; as a key: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;We do not sum projection over only one atom: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">elt</span><span class="p">)</span>

        <span class="n">max_number_figs</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">decrease</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">:</span>
            <span class="n">max_number_figs</span> <span class="o">+=</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>

        <span class="k">if</span> <span class="p">(</span><span class="n">sum_atoms</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">sum_morbs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">):</span>
            <span class="n">number_figs</span> <span class="o">=</span> <span class="n">max_number_figs</span>
        <span class="k">elif</span> <span class="p">(</span><span class="n">sum_atoms</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">sum_morbs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">:</span>
                <span class="n">decrease</span> <span class="o">+=</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>
            <span class="n">number_figs</span> <span class="o">=</span> <span class="n">max_number_figs</span> <span class="o">-</span> <span class="n">decrease</span>
        <span class="k">elif</span> <span class="p">(</span><span class="n">sum_atoms</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">sum_morbs</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">:</span>
                <span class="n">decrease</span> <span class="o">+=</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>
            <span class="n">number_figs</span> <span class="o">=</span> <span class="n">max_number_figs</span> <span class="o">-</span> <span class="n">decrease</span>
        <span class="k">elif</span> <span class="p">(</span><span class="n">sum_atoms</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">sum_morbs</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">:</span>
                <span class="n">decrease</span> <span class="o">+=</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">:</span>
                    <span class="n">decrease</span> <span class="o">+=</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="p">(</span>
                            <span class="nb">len</span><span class="p">(</span><span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">decrease</span> <span class="o">+=</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>
            <span class="n">number_figs</span> <span class="o">=</span> <span class="n">max_number_figs</span> <span class="o">-</span> <span class="n">decrease</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Invalid format of &#39;sum_atoms&#39; and &#39;sum_morbs&#39;.&quot;</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">dictpa</span><span class="p">,</span> <span class="n">sum_atoms</span><span class="p">,</span> <span class="n">number_figs</span>

    <span class="k">def</span> <span class="nf">_summarize_keys_for_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dictio</span><span class="p">,</span> <span class="n">dictpa</span><span class="p">,</span> <span class="n">sum_atoms</span><span class="p">,</span> <span class="n">sum_morbs</span><span class="p">):</span>
        <span class="kn">from</span> <span class="nn">pymatgen.core.periodic_table</span> <span class="kn">import</span> <span class="n">Element</span>
        <span class="n">individual_orbs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;p&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;px&#39;</span><span class="p">,</span> <span class="s1">&#39;py&#39;</span><span class="p">,</span> <span class="s1">&#39;pz&#39;</span><span class="p">],</span>
                           <span class="s1">&#39;d&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;dxy&#39;</span><span class="p">,</span> <span class="s1">&#39;dyz&#39;</span><span class="p">,</span> <span class="s1">&#39;dxz&#39;</span><span class="p">,</span> <span class="s1">&#39;dx2&#39;</span><span class="p">,</span> <span class="s1">&#39;dz2&#39;</span><span class="p">],</span>
                           <span class="s1">&#39;f&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s1">&#39;f_3&#39;</span><span class="p">,</span> <span class="s1">&#39;f_2&#39;</span><span class="p">,</span> <span class="s1">&#39;f_1&#39;</span><span class="p">,</span> <span class="s1">&#39;f0&#39;</span><span class="p">,</span> <span class="s1">&#39;f1&#39;</span><span class="p">,</span> <span class="s1">&#39;f2&#39;</span><span class="p">,</span> <span class="s1">&#39;f3&#39;</span><span class="p">]}</span>

        <span class="k">def</span> <span class="nf">number_label</span><span class="p">(</span><span class="n">list_numbers</span><span class="p">):</span>
            <span class="n">list_numbers</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">list_numbers</span><span class="p">)</span>
            <span class="n">divide</span> <span class="o">=</span> <span class="p">[[]]</span>
            <span class="n">divide</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">list_numbers</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="n">group</span> <span class="o">=</span> <span class="mi">0</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">list_numbers</span><span class="p">)):</span>
                <span class="k">if</span> <span class="n">list_numbers</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">==</span> <span class="n">list_numbers</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="n">divide</span><span class="p">[</span><span class="n">group</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">list_numbers</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">group</span> <span class="o">+=</span> <span class="mi">1</span>
                    <span class="n">divide</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">list_numbers</span><span class="p">[</span><span class="n">i</span><span class="p">]])</span>
            <span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
            <span class="k">for</span> <span class="n">elem</span> <span class="ow">in</span> <span class="n">divide</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">elem</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="n">label</span> <span class="o">+=</span> <span class="nb">str</span><span class="p">(</span><span class="n">elem</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;-&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">elem</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;,&quot;</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">label</span> <span class="o">+=</span> <span class="nb">str</span><span class="p">(</span><span class="n">elem</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot;,&quot;</span>
            <span class="k">return</span> <span class="n">label</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>

        <span class="k">def</span> <span class="nf">orbital_label</span><span class="p">(</span><span class="n">list_orbitals</span><span class="p">):</span>
            <span class="n">divide</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">list_orbitals</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">orb</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="n">divide</span><span class="p">:</span>
                    <span class="n">divide</span><span class="p">[</span><span class="n">orb</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">orb</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">divide</span><span class="p">[</span><span class="n">orb</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="n">divide</span><span class="p">[</span><span class="n">orb</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">orb</span><span class="p">)</span>
            <span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
            <span class="k">for</span> <span class="n">elem</span> <span class="ow">in</span> <span class="n">divide</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">elem</span> <span class="o">==</span> <span class="s1">&#39;s&#39;</span><span class="p">:</span>
                    <span class="n">label</span> <span class="o">+=</span> <span class="s2">&quot;s&quot;</span> <span class="o">+</span> <span class="s2">&quot;,&quot;</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">divide</span><span class="p">[</span><span class="n">elem</span><span class="p">])</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">individual_orbs</span><span class="p">[</span><span class="n">elem</span><span class="p">]):</span>
                        <span class="n">label</span> <span class="o">+=</span> <span class="n">elem</span> <span class="o">+</span> <span class="s2">&quot;,&quot;</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">l</span> <span class="o">=</span> <span class="p">[</span><span class="n">o</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">divide</span><span class="p">[</span><span class="n">elem</span><span class="p">]]</span>
                        <span class="n">label</span> <span class="o">+=</span> <span class="n">elem</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">l</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;[&#39;&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;&#39;]&quot;</span><span class="p">,</span>
                                                                         <span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span>
                            <span class="s2">&quot;&#39;, &#39;&quot;</span><span class="p">,</span> <span class="s2">&quot;-&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;,&quot;</span>
            <span class="k">return</span> <span class="n">label</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>

        <span class="k">if</span> <span class="p">(</span><span class="n">sum_atoms</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">sum_morbs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">):</span>
            <span class="n">dictio_d</span> <span class="o">=</span> <span class="n">dictio</span>
            <span class="n">dictpa_d</span> <span class="o">=</span> <span class="p">{</span><span class="n">elt</span><span class="p">:</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)</span> <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]]</span> <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span>
                        <span class="n">dictpa</span><span class="p">}</span>

        <span class="k">elif</span> <span class="p">(</span><span class="n">sum_atoms</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">sum_morbs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">):</span>
            <span class="n">dictio_d</span> <span class="o">=</span> <span class="n">dictio</span>
            <span class="n">dictpa_d</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">if</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">:</span>
                    <span class="n">_sites</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">sites</span>
                    <span class="n">indices</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">_sites</span><span class="p">)):</span>
                        <span class="k">if</span> <span class="nb">list</span><span class="p">(</span><span class="n">_sites</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">_species</span><span class="o">.</span><span class="n">keys</span><span class="p">())[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="fm">__eq__</span><span class="p">(</span><span class="n">Element</span><span class="p">(</span><span class="n">elt</span><span class="p">)):</span>
                            <span class="n">indices</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
                    <span class="n">flag_1</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">indices</span><span class="p">))</span>
                    <span class="n">flag_2</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">indices</span><span class="p">))</span>
                    <span class="k">if</span> <span class="n">flag_1</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">indices</span><span class="p">)</span> <span class="ow">and</span> <span class="n">flag_2</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">indices</span><span class="p">):</span>
                        <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;all&#39;</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="k">if</span> <span class="n">anum</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">))</span>
                        <span class="n">label</span> <span class="o">=</span> <span class="n">number_label</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>
                        <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">label</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                        <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">))</span>

        <span class="k">elif</span> <span class="p">(</span><span class="n">sum_atoms</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">and</span> <span class="p">(</span><span class="n">sum_morbs</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">):</span>
            <span class="n">dictio_d</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">:</span>
                <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">if</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                        <span class="k">if</span> <span class="n">morb</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">morb</span><span class="p">)</span>
                    <span class="n">label</span> <span class="o">=</span> <span class="n">orbital_label</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>
                    <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">label</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span>
            <span class="n">dictpa_d</span> <span class="o">=</span> <span class="p">{</span><span class="n">elt</span><span class="p">:</span> <span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">)</span> <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]]</span> <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span>
                        <span class="n">dictpa</span><span class="p">}</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="n">dictio_d</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">:</span>
                <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">if</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">morb</span> <span class="ow">in</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                        <span class="k">if</span> <span class="n">morb</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">morb</span><span class="p">)</span>
                    <span class="n">label</span> <span class="o">=</span> <span class="n">orbital_label</span><span class="p">(</span><span class="n">sum_morbs</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>
                    <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">label</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">dictio_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="n">dictio</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span>
            <span class="n">dictpa_d</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">for</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">:</span>
                <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">if</span> <span class="n">elt</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">:</span>
                    <span class="n">_sites</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bs</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">sites</span>
                    <span class="n">indices</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">_sites</span><span class="p">)):</span>
                        <span class="k">if</span> <span class="nb">list</span><span class="p">(</span><span class="n">_sites</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">_species</span><span class="o">.</span><span class="n">keys</span><span class="p">())[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="fm">__eq__</span><span class="p">(</span><span class="n">Element</span><span class="p">(</span><span class="n">elt</span><span class="p">)):</span>
                            <span class="n">indices</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
                    <span class="n">flag_1</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">indices</span><span class="p">))</span>
                    <span class="n">flag_2</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">indices</span><span class="p">))</span>
                    <span class="k">if</span> <span class="n">flag_1</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">indices</span><span class="p">)</span> <span class="ow">and</span> <span class="n">flag_2</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">indices</span><span class="p">):</span>
                        <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;all&#39;</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                            <span class="k">if</span> <span class="n">anum</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                                <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">))</span>
                        <span class="n">label</span> <span class="o">=</span> <span class="n">number_label</span><span class="p">(</span><span class="n">sum_atoms</span><span class="p">[</span><span class="n">elt</span><span class="p">])</span>
                        <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">label</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">anum</span> <span class="ow">in</span> <span class="n">dictpa</span><span class="p">[</span><span class="n">elt</span><span class="p">]:</span>
                        <span class="n">dictpa_d</span><span class="p">[</span><span class="n">elt</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">anum</span><span class="p">))</span>

        <span class="k">return</span> <span class="n">dictio_d</span><span class="p">,</span> <span class="n">dictpa_d</span>

    <span class="k">def</span> <span class="nf">_maketicks_selected</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">plt</span><span class="p">,</span> <span class="n">branches</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        utility private method to add ticks to a band structure with selected branches</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">ticks</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_ticks</span><span class="p">()</span>
        <span class="n">distance</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">label</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">rm_elems</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">])):</span>
            <span class="k">if</span> <span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">==</span> <span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]:</span>
                <span class="n">rm_elems</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">])):</span>
            <span class="k">if</span> <span class="n">i</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">rm_elems</span><span class="p">:</span>
                <span class="n">distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">])</span>
                <span class="n">label</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">])</span>
        <span class="n">l_branches</span> <span class="o">=</span> <span class="p">[</span><span class="n">distance</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">-</span> <span class="n">distance</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span>
                      <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">distance</span><span class="p">))]</span>
        <span class="n">n_distance</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">n_label</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">branch</span> <span class="ow">in</span> <span class="n">branches</span><span class="p">:</span>
            <span class="n">n_distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l_branches</span><span class="p">[</span><span class="n">branch</span><span class="p">])</span>
            <span class="k">if</span> <span class="p">(</span><span class="s2">&quot;$</span><span class="se">\\</span><span class="s2">mid$&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">label</span><span class="p">[</span><span class="n">branch</span><span class="p">])</span> <span class="ow">and</span> <span class="p">(</span>
                    <span class="s2">&quot;$</span><span class="se">\\</span><span class="s2">mid$&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">label</span><span class="p">[</span><span class="n">branch</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]):</span>
                <span class="n">n_label</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">label</span><span class="p">[</span><span class="n">branch</span><span class="p">],</span> <span class="n">label</span><span class="p">[</span><span class="n">branch</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]])</span>
            <span class="k">elif</span> <span class="p">(</span><span class="s2">&quot;$</span><span class="se">\\</span><span class="s2">mid$&quot;</span> <span class="ow">in</span> <span class="n">label</span><span class="p">[</span><span class="n">branch</span><span class="p">])</span> <span class="ow">and</span> <span class="p">(</span>
                    <span class="s2">&quot;$</span><span class="se">\\</span><span class="s2">mid$&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">label</span><span class="p">[</span><span class="n">branch</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]):</span>
                <span class="n">n_label</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="p">[</span><span class="n">label</span><span class="p">[</span><span class="n">branch</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;$&quot;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">label</span><span class="p">[</span><span class="n">branch</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]])</span>
            <span class="k">elif</span> <span class="p">(</span><span class="s2">&quot;$</span><span class="se">\\</span><span class="s2">mid$&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">label</span><span class="p">[</span><span class="n">branch</span><span class="p">])</span> <span class="ow">and</span> <span class="p">(</span>
                    <span class="s2">&quot;$</span><span class="se">\\</span><span class="s2">mid$&quot;</span> <span class="ow">in</span> <span class="n">label</span><span class="p">[</span><span class="n">branch</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]):</span>
                <span class="n">n_label</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">label</span><span class="p">[</span><span class="n">branch</span><span class="p">],</span> <span class="n">label</span><span class="p">[</span><span class="n">branch</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;$&quot;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">n_label</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">label</span><span class="p">[</span><span class="n">branch</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;$&quot;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span>
                                <span class="n">label</span><span class="p">[</span><span class="n">branch</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;$&quot;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]])</span>

        <span class="n">f_distance</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">rf_distance</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">f_label</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">f_label</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">n_label</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">f_label</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">n_label</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span>
        <span class="n">f_distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.0</span><span class="p">)</span>
        <span class="n">f_distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">n_distance</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">rf_distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.0</span><span class="p">)</span>
        <span class="n">rf_distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">n_distance</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">length</span> <span class="o">=</span> <span class="n">n_distance</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">n_distance</span><span class="p">)):</span>
            <span class="k">if</span> <span class="n">n_label</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="n">n_label</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]:</span>
                <span class="n">f_distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">length</span><span class="p">)</span>
                <span class="n">f_distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">length</span> <span class="o">+</span> <span class="n">n_distance</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                <span class="n">f_label</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">n_label</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">f_label</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">n_label</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">f_distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">length</span> <span class="o">+</span> <span class="n">n_distance</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                <span class="n">f_label</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">n_label</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;$</span><span class="se">\\</span><span class="s2">mid$&quot;</span> <span class="o">+</span> <span class="n">n_label</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
                <span class="n">f_label</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">n_label</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span>
            <span class="n">rf_distance</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">length</span> <span class="o">+</span> <span class="n">n_distance</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
            <span class="n">length</span> <span class="o">+=</span> <span class="n">n_distance</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>

        <span class="n">n_ticks</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;distance&#39;</span><span class="p">:</span> <span class="n">f_distance</span><span class="p">,</span> <span class="s1">&#39;label&#39;</span><span class="p">:</span> <span class="n">f_label</span><span class="p">}</span>
        <span class="n">uniq_d</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">uniq_l</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">temp_ticks</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">],</span> <span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">]))</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">temp_ticks</span><span class="p">)):</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">uniq_d</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">uniq_l</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span>
                <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Adding label </span><span class="si">{l}</span><span class="s2"> at </span><span class="si">{d}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">l</span><span class="o">=</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="n">d</span><span class="o">=</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]:</span>
                    <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Skipping label </span><span class="si">{i}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">i</span><span class="o">=</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Adding label </span><span class="si">{l}</span><span class="s2"> at </span><span class="si">{d}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">l</span><span class="o">=</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="n">d</span><span class="o">=</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">]))</span>
                    <span class="n">uniq_d</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">0</span><span class="p">])</span>
                    <span class="n">uniq_l</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">temp_ticks</span><span class="p">[</span><span class="n">i</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span>

        <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Unique labels are </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">uniq_d</span><span class="p">,</span> <span class="n">uniq_l</span><span class="p">)))</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">set_xticks</span><span class="p">(</span><span class="n">uniq_d</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">set_xticklabels</span><span class="p">(</span><span class="n">uniq_l</span><span class="p">)</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">])):</span>
            <span class="k">if</span> <span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="c1"># don&#39;t print the same label twice</span>
                <span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="o">==</span> <span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]:</span>
                        <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;already print label... &quot;</span>
                                     <span class="s2">&quot;skipping label </span><span class="si">{i}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">i</span><span class="o">=</span><span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]))</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Adding a line at </span><span class="si">{d}</span><span class="s2">&quot;</span>
                                     <span class="s2">&quot; for label </span><span class="si">{l}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">d</span><span class="o">=</span><span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">l</span><span class="o">=</span><span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]))</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">axvline</span><span class="p">(</span><span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">)</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Adding a line at </span><span class="si">{d}</span><span class="s2"> for label </span><span class="si">{l}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">d</span><span class="o">=</span><span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">l</span><span class="o">=</span><span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">]))</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">axvline</span><span class="p">(</span><span class="n">n_ticks</span><span class="p">[</span><span class="s1">&#39;distance&#39;</span><span class="p">][</span><span class="n">i</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">)</span>

        <span class="n">shift</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">br</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
        <span class="k">for</span> <span class="n">branch</span> <span class="ow">in</span> <span class="n">branches</span><span class="p">:</span>
            <span class="n">br</span> <span class="o">+=</span> <span class="mi">1</span>
            <span class="n">shift</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">distance</span><span class="p">[</span><span class="n">branch</span><span class="p">]</span> <span class="o">-</span> <span class="n">rf_distance</span><span class="p">[</span><span class="n">br</span><span class="p">])</span>

        <span class="k">return</span> <span class="n">plt</span><span class="p">,</span> <span class="n">shift</span></div>


<div class="viewcode-block" id="BSDOSPlotter"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSDOSPlotter">[docs]</a><span class="k">class</span> <span class="nc">BSDOSPlotter</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    A joint, aligned band structure and density of states plot. Contributions</span>
<span class="sd">    from Jan Pohls as well as the online example from Germain Salvato-Vallverdu:</span>
<span class="sd">    http://gvallver.perso.univ-pau.fr/?p=587</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">bs_projection</span><span class="o">=</span><span class="s2">&quot;elements&quot;</span><span class="p">,</span> <span class="n">dos_projection</span><span class="o">=</span><span class="s2">&quot;elements&quot;</span><span class="p">,</span>
                 <span class="n">vb_energy_range</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">cb_energy_range</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">fixed_cb_energy</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                 <span class="n">egrid_interval</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">font</span><span class="o">=</span><span class="s2">&quot;Times New Roman&quot;</span><span class="p">,</span> <span class="n">axis_fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">,</span>
                 <span class="n">tick_fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">,</span> <span class="n">legend_fontsize</span><span class="o">=</span><span class="mi">14</span><span class="p">,</span> <span class="n">bs_legend</span><span class="o">=</span><span class="s2">&quot;best&quot;</span><span class="p">,</span>
                 <span class="n">dos_legend</span><span class="o">=</span><span class="s2">&quot;best&quot;</span><span class="p">,</span> <span class="n">rgb_legend</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">fig_size</span><span class="o">=</span><span class="p">(</span><span class="mi">11</span><span class="p">,</span> <span class="mf">8.5</span><span class="p">)):</span>

        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Instantiate plotter settings.</span>

<span class="sd">        Args:</span>
<span class="sd">            bs_projection (str): &quot;elements&quot; or None</span>
<span class="sd">            dos_projection (str): &quot;elements&quot;, &quot;orbitals&quot;, or None</span>
<span class="sd">            vb_energy_range (float): energy in eV to show of valence bands</span>
<span class="sd">            cb_energy_range (float): energy in eV to show of conduction bands</span>
<span class="sd">            fixed_cb_energy (bool): If true, the cb_energy_range will be interpreted</span>
<span class="sd">                as constant (i.e., no gap correction for cb energy)</span>
<span class="sd">            egrid_interval (float): interval for grid marks</span>
<span class="sd">            font (str): font family</span>
<span class="sd">            axis_fontsize (float): font size for axis</span>
<span class="sd">            tick_fontsize (float): font size for axis tick labels</span>
<span class="sd">            legend_fontsize (float): font size for legends</span>
<span class="sd">            bs_legend (str): matplotlib string location for legend or None</span>
<span class="sd">            dos_legend (str): matplotlib string location for legend or None</span>
<span class="sd">            rgb_legend (bool): (T/F) whether to draw RGB triangle/bar for element proj.</span>
<span class="sd">            fig_size(tuple): dimensions of figure size (width, height)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">bs_projection</span> <span class="o">=</span> <span class="n">bs_projection</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dos_projection</span> <span class="o">=</span> <span class="n">dos_projection</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">vb_energy_range</span> <span class="o">=</span> <span class="n">vb_energy_range</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cb_energy_range</span> <span class="o">=</span> <span class="n">cb_energy_range</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fixed_cb_energy</span> <span class="o">=</span> <span class="n">fixed_cb_energy</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">egrid_interval</span> <span class="o">=</span> <span class="n">egrid_interval</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">font</span> <span class="o">=</span> <span class="n">font</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">axis_fontsize</span> <span class="o">=</span> <span class="n">axis_fontsize</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">tick_fontsize</span> <span class="o">=</span> <span class="n">tick_fontsize</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">legend_fontsize</span> <span class="o">=</span> <span class="n">legend_fontsize</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">bs_legend</span> <span class="o">=</span> <span class="n">bs_legend</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dos_legend</span> <span class="o">=</span> <span class="n">dos_legend</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rgb_legend</span> <span class="o">=</span> <span class="n">rgb_legend</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fig_size</span> <span class="o">=</span> <span class="n">fig_size</span>

<div class="viewcode-block" id="BSDOSPlotter.get_plot"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BSDOSPlotter.get_plot">[docs]</a>    <span class="k">def</span> <span class="nf">get_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">bs</span><span class="p">,</span> <span class="n">dos</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get a matplotlib plot object.</span>
<span class="sd">        Args:</span>
<span class="sd">            bs (BandStructureSymmLine): the bandstructure to plot. Projection</span>
<span class="sd">                data must exist for projected plots.</span>
<span class="sd">            dos (Dos): the Dos to plot. Projection data must exist (i.e.,</span>
<span class="sd">                CompleteDos) for projected plots.</span>

<span class="sd">        Returns:</span>
<span class="sd">            matplotlib.pyplot object on which you can call commands like show()</span>
<span class="sd">            and savefig()</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.lines</span> <span class="k">as</span> <span class="nn">mlines</span>
        <span class="kn">from</span> <span class="nn">matplotlib.gridspec</span> <span class="kn">import</span> <span class="n">GridSpec</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">mplt</span>

        <span class="c1"># make sure the user-specified band structure projection is valid</span>
        <span class="n">bs_projection</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">bs_projection</span>
        <span class="k">if</span> <span class="n">dos</span><span class="p">:</span>
            <span class="n">elements</span> <span class="o">=</span> <span class="p">[</span><span class="n">e</span><span class="o">.</span><span class="n">symbol</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">dos</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">elements</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">bs_projection</span> <span class="ow">and</span> <span class="n">bs</span><span class="o">.</span><span class="n">structure</span><span class="p">:</span>
            <span class="n">elements</span> <span class="o">=</span> <span class="p">[</span><span class="n">e</span><span class="o">.</span><span class="n">symbol</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">bs</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">elements</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">elements</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="n">rgb_legend</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">rgb_legend</span> <span class="ow">and</span> <span class="n">bs_projection</span> <span class="ow">and</span> <span class="n">bs_projection</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;elements&quot;</span> <span class="ow">and</span> \
            <span class="nb">len</span><span class="p">(</span><span class="n">elements</span><span class="p">)</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span>

        <span class="k">if</span> <span class="n">bs_projection</span> <span class="ow">and</span> <span class="n">bs_projection</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;elements&quot;</span> <span class="ow">and</span> \
                <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">elements</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]</span> <span class="ow">or</span>
                 <span class="ow">not</span> <span class="n">bs</span><span class="o">.</span><span class="n">get_projection_on_elements</span><span class="p">()):</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                <span class="s2">&quot;Cannot get element projected data; either the projection data &quot;</span>
                <span class="s2">&quot;doesn&#39;t exist, or you don&#39;t have a compound with exactly 2 &quot;</span>
                <span class="s2">&quot;or 3 unique elements.&quot;</span><span class="p">)</span>
            <span class="n">bs_projection</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="c1"># specify energy range of plot</span>
        <span class="n">emin</span> <span class="o">=</span> <span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">vb_energy_range</span>
        <span class="n">emax</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">cb_energy_range</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fixed_cb_energy</span> <span class="k">else</span> \
            <span class="bp">self</span><span class="o">.</span><span class="n">cb_energy_range</span> <span class="o">+</span> <span class="n">bs</span><span class="o">.</span><span class="n">get_band_gap</span><span class="p">()[</span><span class="s2">&quot;energy&quot;</span><span class="p">]</span>

        <span class="c1"># initialize all the k-point labels and k-point x-distances for bs plot</span>
        <span class="n">xlabels</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># all symmetry point labels on x-axis</span>
        <span class="n">xlabel_distances</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># positions of symmetry point x-labels</span>

        <span class="n">x_distances_list</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">prev_right_klabel</span> <span class="o">=</span> <span class="kc">None</span>  <span class="c1"># used to determine which branches require a midline separator</span>

        <span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">l</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">bs</span><span class="o">.</span><span class="n">branches</span><span class="p">):</span>
            <span class="n">x_distances</span> <span class="o">=</span> <span class="p">[]</span>

            <span class="c1"># get left and right kpoint labels of this branch</span>
            <span class="n">left_k</span><span class="p">,</span> <span class="n">right_k</span> <span class="o">=</span> <span class="n">l</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;-&quot;</span><span class="p">)</span>

            <span class="c1"># add $ notation for LaTeX kpoint labels</span>
            <span class="k">if</span> <span class="n">left_k</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span> <span class="ow">or</span> <span class="s2">&quot;_&quot;</span> <span class="ow">in</span> <span class="n">left_k</span><span class="p">:</span>
                <span class="n">left_k</span> <span class="o">=</span> <span class="s2">&quot;$&quot;</span> <span class="o">+</span> <span class="n">left_k</span> <span class="o">+</span> <span class="s2">&quot;$&quot;</span>
            <span class="k">if</span> <span class="n">right_k</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span> <span class="ow">or</span> <span class="s2">&quot;_&quot;</span> <span class="ow">in</span> <span class="n">right_k</span><span class="p">:</span>
                <span class="n">right_k</span> <span class="o">=</span> <span class="s2">&quot;$&quot;</span> <span class="o">+</span> <span class="n">right_k</span> <span class="o">+</span> <span class="s2">&quot;$&quot;</span>

            <span class="c1"># add left k label to list of labels</span>
            <span class="k">if</span> <span class="n">prev_right_klabel</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">xlabels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">left_k</span><span class="p">)</span>
                <span class="n">xlabel_distances</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
            <span class="k">elif</span> <span class="n">prev_right_klabel</span> <span class="o">!=</span> <span class="n">left_k</span><span class="p">:</span>  <span class="c1"># used for pipe separator</span>
                <span class="n">xlabels</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">xlabels</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="s2">&quot;$</span><span class="se">\\</span><span class="s2">mid$ &quot;</span> <span class="o">+</span> <span class="n">left_k</span>

            <span class="c1"># add right k label to list of labels</span>
            <span class="n">xlabels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">right_k</span><span class="p">)</span>
            <span class="n">prev_right_klabel</span> <span class="o">=</span> <span class="n">right_k</span>

            <span class="c1"># add x-coordinates for labels</span>
            <span class="n">left_kpoint</span> <span class="o">=</span> <span class="n">bs</span><span class="o">.</span><span class="n">kpoints</span><span class="p">[</span><span class="n">l</span><span class="p">[</span><span class="s2">&quot;start_index&quot;</span><span class="p">]]</span><span class="o">.</span><span class="n">cart_coords</span>
            <span class="n">right_kpoint</span> <span class="o">=</span> <span class="n">bs</span><span class="o">.</span><span class="n">kpoints</span><span class="p">[</span><span class="n">l</span><span class="p">[</span><span class="s2">&quot;end_index&quot;</span><span class="p">]]</span><span class="o">.</span><span class="n">cart_coords</span>
            <span class="n">distance</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">right_kpoint</span> <span class="o">-</span> <span class="n">left_kpoint</span><span class="p">)</span>
            <span class="n">xlabel_distances</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">xlabel_distances</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">distance</span><span class="p">)</span>

            <span class="c1"># add x-coordinates for kpoint data</span>
            <span class="n">npts</span> <span class="o">=</span> <span class="n">l</span><span class="p">[</span><span class="s2">&quot;end_index&quot;</span><span class="p">]</span> <span class="o">-</span> <span class="n">l</span><span class="p">[</span><span class="s2">&quot;start_index&quot;</span><span class="p">]</span>
            <span class="n">distance_interval</span> <span class="o">=</span> <span class="n">distance</span> <span class="o">/</span> <span class="n">npts</span>
            <span class="n">x_distances</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">xlabel_distances</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">])</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">npts</span><span class="p">):</span>
                <span class="n">x_distances</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">x_distances</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">distance_interval</span><span class="p">)</span>
            <span class="n">x_distances_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">x_distances</span><span class="p">)</span>

        <span class="c1"># set up bs and dos plot</span>
        <span class="n">gs</span> <span class="o">=</span> <span class="n">GridSpec</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="n">width_ratios</span><span class="o">=</span><span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span> <span class="k">if</span> <span class="n">dos</span> <span class="k">else</span> <span class="n">GridSpec</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>

        <span class="n">fig</span> <span class="o">=</span> <span class="n">mplt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">fig_size</span><span class="p">)</span>
        <span class="n">fig</span><span class="o">.</span><span class="n">patch</span><span class="o">.</span><span class="n">set_facecolor</span><span class="p">(</span><span class="s1">&#39;white&#39;</span><span class="p">)</span>
        <span class="n">bs_ax</span> <span class="o">=</span> <span class="n">mplt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">gs</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="k">if</span> <span class="n">dos</span><span class="p">:</span>
            <span class="n">dos_ax</span> <span class="o">=</span> <span class="n">mplt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="n">gs</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>

        <span class="c1"># set basic axes limits for the plot</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">x_distances_list</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">(</span><span class="n">emin</span><span class="p">,</span> <span class="n">emax</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">dos</span><span class="p">:</span>
            <span class="n">dos_ax</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">(</span><span class="n">emin</span><span class="p">,</span> <span class="n">emax</span><span class="p">)</span>

        <span class="c1"># add BS xticks, labels, etc.</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">set_xticks</span><span class="p">(</span><span class="n">xlabel_distances</span><span class="p">)</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">set_xticklabels</span><span class="p">(</span><span class="n">xlabels</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">tick_fontsize</span><span class="p">)</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;Wavevector $k$&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">axis_fontsize</span><span class="p">,</span>
                         <span class="n">family</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">font</span><span class="p">)</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s1">&#39;$E-E_F$ / eV&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">axis_fontsize</span><span class="p">,</span>
                         <span class="n">family</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">font</span><span class="p">)</span>

        <span class="c1"># add BS fermi level line at E=0 and gridlines</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">hlines</span><span class="p">(</span><span class="n">y</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">xmin</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">xmax</span><span class="o">=</span><span class="n">x_distances_list</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s2">&quot;k&quot;</span><span class="p">,</span> <span class="n">lw</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">set_yticks</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">emin</span><span class="p">,</span> <span class="n">emax</span> <span class="o">+</span> <span class="mf">1E-5</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">egrid_interval</span><span class="p">))</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">set_yticklabels</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">emin</span><span class="p">,</span> <span class="n">emax</span> <span class="o">+</span> <span class="mf">1E-5</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">egrid_interval</span><span class="p">),</span>
                              <span class="n">size</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">tick_fontsize</span><span class="p">)</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">set_axisbelow</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
        <span class="n">bs_ax</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">color</span><span class="o">=</span><span class="p">[</span><span class="mf">0.5</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">],</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;dotted&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">dos</span><span class="p">:</span>
            <span class="n">dos_ax</span><span class="o">.</span><span class="n">set_yticks</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">emin</span><span class="p">,</span> <span class="n">emax</span> <span class="o">+</span> <span class="mf">1E-5</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">egrid_interval</span><span class="p">))</span>
            <span class="n">dos_ax</span><span class="o">.</span><span class="n">set_yticklabels</span><span class="p">([])</span>
            <span class="n">dos_ax</span><span class="o">.</span><span class="n">grid</span><span class="p">(</span><span class="n">color</span><span class="o">=</span><span class="p">[</span><span class="mf">0.5</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">],</span> <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;dotted&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>

        <span class="c1"># renormalize the band energy to the Fermi level</span>
        <span class="n">band_energies</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">spin</span> <span class="ow">in</span> <span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">,</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">spin</span> <span class="ow">in</span> <span class="n">bs</span><span class="o">.</span><span class="n">bands</span><span class="p">:</span>
                <span class="n">band_energies</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">band</span> <span class="ow">in</span> <span class="n">bs</span><span class="o">.</span><span class="n">bands</span><span class="p">[</span><span class="n">spin</span><span class="p">]:</span>
                    <span class="n">band_energies</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">e</span> <span class="o">-</span> <span class="n">bs</span><span class="o">.</span><span class="n">efermi</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">band</span><span class="p">])</span>

        <span class="c1"># renormalize the DOS energies to Fermi level</span>
        <span class="k">if</span> <span class="n">dos</span><span class="p">:</span>
            <span class="n">dos_energies</span> <span class="o">=</span> <span class="p">[</span><span class="n">e</span> <span class="o">-</span> <span class="n">dos</span><span class="o">.</span><span class="n">efermi</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">dos</span><span class="o">.</span><span class="n">energies</span><span class="p">]</span>

        <span class="c1"># get the projection data to set colors for the band structure</span>
        <span class="n">colordata</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_colordata</span><span class="p">(</span><span class="n">bs</span><span class="p">,</span> <span class="n">elements</span><span class="p">,</span> <span class="n">bs_projection</span><span class="p">)</span>

        <span class="c1"># plot the colored band structure lines</span>
        <span class="k">for</span> <span class="n">spin</span> <span class="ow">in</span> <span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">,</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">spin</span> <span class="ow">in</span> <span class="n">band_energies</span><span class="p">:</span>
                <span class="n">linestyles</span> <span class="o">=</span> <span class="s2">&quot;solid&quot;</span> <span class="k">if</span> <span class="n">spin</span> <span class="o">==</span> <span class="n">Spin</span><span class="o">.</span><span class="n">up</span> <span class="k">else</span> <span class="s2">&quot;dotted&quot;</span>
                <span class="k">for</span> <span class="n">band_idx</span><span class="p">,</span> <span class="n">band</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">band_energies</span><span class="p">[</span><span class="n">spin</span><span class="p">]):</span>
                    <span class="n">current_pos</span> <span class="o">=</span> <span class="mi">0</span>
                    <span class="k">for</span> <span class="n">x_distances</span> <span class="ow">in</span> <span class="n">x_distances_list</span><span class="p">:</span>
                        <span class="n">sub_band</span> <span class="o">=</span> <span class="n">band</span><span class="p">[</span><span class="n">current_pos</span><span class="p">:</span> <span class="n">current_pos</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="n">x_distances</span><span class="p">)]</span>

                        <span class="bp">self</span><span class="o">.</span><span class="n">_rgbline</span><span class="p">(</span><span class="n">bs_ax</span><span class="p">,</span> <span class="n">x_distances</span><span class="p">,</span> <span class="n">sub_band</span><span class="p">,</span>
                                      <span class="n">colordata</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="n">band_idx</span><span class="p">,</span> <span class="p">:,</span> <span class="mi">0</span><span class="p">][</span><span class="n">current_pos</span><span class="p">:</span> <span class="n">current_pos</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="n">x_distances</span><span class="p">)],</span>
                                      <span class="n">colordata</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="n">band_idx</span><span class="p">,</span> <span class="p">:,</span> <span class="mi">1</span><span class="p">][</span><span class="n">current_pos</span><span class="p">:</span> <span class="n">current_pos</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="n">x_distances</span><span class="p">)],</span>
                                      <span class="n">colordata</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="n">band_idx</span><span class="p">,</span> <span class="p">:,</span> <span class="mi">2</span><span class="p">][</span><span class="n">current_pos</span><span class="p">:</span> <span class="n">current_pos</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="n">x_distances</span><span class="p">)],</span>
                                      <span class="n">linestyles</span><span class="o">=</span><span class="n">linestyles</span><span class="p">)</span>

                        <span class="n">current_pos</span> <span class="o">+=</span> <span class="nb">len</span><span class="p">(</span><span class="n">x_distances</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">dos</span><span class="p">:</span>
            <span class="c1"># Plot the DOS and projected DOS</span>
            <span class="k">for</span> <span class="n">spin</span> <span class="ow">in</span> <span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">,</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">spin</span> <span class="ow">in</span> <span class="n">dos</span><span class="o">.</span><span class="n">densities</span><span class="p">:</span>
                    <span class="c1"># plot the total DOS</span>
                    <span class="n">dos_densities</span> <span class="o">=</span> <span class="n">dos</span><span class="o">.</span><span class="n">densities</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">*</span> <span class="nb">int</span><span class="p">(</span><span class="n">spin</span><span class="p">)</span>
                    <span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;total&quot;</span> <span class="k">if</span> <span class="n">spin</span> <span class="o">==</span> <span class="n">Spin</span><span class="o">.</span><span class="n">up</span> <span class="k">else</span> <span class="kc">None</span>
                    <span class="n">dos_ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">dos_densities</span><span class="p">,</span> <span class="n">dos_energies</span><span class="p">,</span>
                                <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mf">0.6</span><span class="p">,</span> <span class="mf">0.6</span><span class="p">,</span> <span class="mf">0.6</span><span class="p">),</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">)</span>
                    <span class="n">dos_ax</span><span class="o">.</span><span class="n">fill_betweenx</span><span class="p">(</span><span class="n">dos_energies</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">dos_densities</span><span class="p">,</span>
                                         <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mf">0.7</span><span class="p">,</span> <span class="mf">0.7</span><span class="p">,</span> <span class="mf">0.7</span><span class="p">),</span>
                                         <span class="n">facecolor</span><span class="o">=</span><span class="p">(</span><span class="mf">0.7</span><span class="p">,</span> <span class="mf">0.7</span><span class="p">,</span> <span class="mf">0.7</span><span class="p">))</span>

                    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dos_projection</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                        <span class="k">pass</span>

                    <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">dos_projection</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;elements&quot;</span><span class="p">:</span>
                        <span class="c1"># plot the atom-projected DOS</span>
                        <span class="n">colors</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">,</span> <span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="s1">&#39;m&#39;</span><span class="p">,</span> <span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">,</span> <span class="s1">&#39;k&#39;</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">]</span>
                        <span class="n">el_dos</span> <span class="o">=</span> <span class="n">dos</span><span class="o">.</span><span class="n">get_element_dos</span><span class="p">()</span>
                        <span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">el</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">elements</span><span class="p">):</span>
                            <span class="n">dos_densities</span> <span class="o">=</span> <span class="n">el_dos</span><span class="p">[</span><span class="n">Element</span><span class="p">(</span><span class="n">el</span><span class="p">)]</span><span class="o">.</span><span class="n">densities</span><span class="p">[</span>
                                                <span class="n">spin</span><span class="p">]</span> <span class="o">*</span> <span class="nb">int</span><span class="p">(</span><span class="n">spin</span><span class="p">)</span>
                            <span class="n">label</span> <span class="o">=</span> <span class="n">el</span> <span class="k">if</span> <span class="n">spin</span> <span class="o">==</span> <span class="n">Spin</span><span class="o">.</span><span class="n">up</span> <span class="k">else</span> <span class="kc">None</span>
                            <span class="n">dos_ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">dos_densities</span><span class="p">,</span> <span class="n">dos_energies</span><span class="p">,</span>
                                        <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">idx</span><span class="p">],</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">)</span>

                    <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">dos_projection</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;orbitals&quot;</span><span class="p">:</span>
                        <span class="c1"># plot each of the atomic projected DOS</span>
                        <span class="n">colors</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">,</span> <span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="s1">&#39;m&#39;</span><span class="p">]</span>
                        <span class="n">spd_dos</span> <span class="o">=</span> <span class="n">dos</span><span class="o">.</span><span class="n">get_spd_dos</span><span class="p">()</span>
                        <span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">orb</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="n">OrbitalType</span><span class="o">.</span><span class="n">s</span><span class="p">,</span>
                                                   <span class="n">OrbitalType</span><span class="o">.</span><span class="n">p</span><span class="p">,</span>
                                                   <span class="n">OrbitalType</span><span class="o">.</span><span class="n">d</span><span class="p">,</span>
                                                   <span class="n">OrbitalType</span><span class="o">.</span><span class="n">f</span><span class="p">]):</span>
                            <span class="k">if</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">spd_dos</span><span class="p">:</span>
                                <span class="n">dos_densities</span> <span class="o">=</span> <span class="n">spd_dos</span><span class="p">[</span><span class="n">orb</span><span class="p">]</span><span class="o">.</span><span class="n">densities</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">*</span> \
                                                <span class="nb">int</span><span class="p">(</span><span class="n">spin</span><span class="p">)</span>
                                <span class="n">label</span> <span class="o">=</span> <span class="n">orb</span> <span class="k">if</span> <span class="n">spin</span> <span class="o">==</span> <span class="n">Spin</span><span class="o">.</span><span class="n">up</span> <span class="k">else</span> <span class="kc">None</span>
                                <span class="n">dos_ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">dos_densities</span><span class="p">,</span> <span class="n">dos_energies</span><span class="p">,</span>
                                            <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">idx</span><span class="p">],</span> <span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">)</span>

            <span class="c1"># get index of lowest and highest energy being plotted, used to help auto-scale DOS x-axis</span>
            <span class="n">emin_idx</span> <span class="o">=</span> <span class="nb">next</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">dos_energies</span><span class="p">)</span> <span class="k">if</span>
                            <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">&gt;=</span> <span class="n">emin</span><span class="p">)</span>
            <span class="n">emax_idx</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">dos_energies</span><span class="p">)</span> <span class="o">-</span> <span class="nb">next</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">reversed</span><span class="p">(</span><span class="n">dos_energies</span><span class="p">))</span> <span class="k">if</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">&lt;=</span> <span class="n">emax</span><span class="p">)</span>

            <span class="c1"># determine DOS x-axis range</span>
            <span class="n">dos_xmin</span> <span class="o">=</span> <span class="mi">0</span> <span class="k">if</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">dos</span><span class="o">.</span><span class="n">densities</span> <span class="k">else</span> <span class="o">-</span><span class="nb">max</span><span class="p">(</span>
                <span class="n">dos</span><span class="o">.</span><span class="n">densities</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">][</span><span class="n">emin_idx</span><span class="p">:</span><span class="n">emax_idx</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="mf">1.05</span><span class="p">)</span>
            <span class="n">dos_xmax</span> <span class="o">=</span> <span class="nb">max</span><span class="p">([</span><span class="nb">max</span><span class="p">(</span><span class="n">dos</span><span class="o">.</span><span class="n">densities</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">][</span><span class="n">emin_idx</span><span class="p">:</span><span class="n">emax_idx</span><span class="p">])</span> <span class="o">*</span>
                            <span class="mf">1.05</span><span class="p">,</span> <span class="nb">abs</span><span class="p">(</span><span class="n">dos_xmin</span><span class="p">)])</span>

            <span class="c1"># set up the DOS x-axis and add Fermi level line</span>
            <span class="n">dos_ax</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">(</span><span class="n">dos_xmin</span><span class="p">,</span> <span class="n">dos_xmax</span><span class="p">)</span>
            <span class="n">dos_ax</span><span class="o">.</span><span class="n">set_xticklabels</span><span class="p">([])</span>
            <span class="n">dos_ax</span><span class="o">.</span><span class="n">hlines</span><span class="p">(</span><span class="n">y</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">xmin</span><span class="o">=</span><span class="n">dos_xmin</span><span class="p">,</span> <span class="n">xmax</span><span class="o">=</span><span class="n">dos_xmax</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s2">&quot;k&quot;</span><span class="p">,</span> <span class="n">lw</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
            <span class="n">dos_ax</span><span class="o">.</span><span class="n">set_xlabel</span><span class="p">(</span><span class="s1">&#39;DOS&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">axis_fontsize</span><span class="p">,</span>
                              <span class="n">family</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">font</span><span class="p">)</span>

        <span class="c1"># add legend for band structure</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bs_legend</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">rgb_legend</span><span class="p">:</span>
            <span class="n">handles</span> <span class="o">=</span> <span class="p">[]</span>

            <span class="k">if</span> <span class="n">bs_projection</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">handles</span> <span class="o">=</span> <span class="p">[</span><span class="n">mlines</span><span class="o">.</span><span class="n">Line2D</span><span class="p">([],</span> <span class="p">[],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
                                         <span class="n">color</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s1">&#39;spin up&#39;</span><span class="p">),</span>
                           <span class="n">mlines</span><span class="o">.</span><span class="n">Line2D</span><span class="p">([],</span> <span class="p">[],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
                                         <span class="n">color</span><span class="o">=</span><span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="n">linestyle</span><span class="o">=</span><span class="s2">&quot;dotted&quot;</span><span class="p">,</span>
                                         <span class="n">label</span><span class="o">=</span><span class="s1">&#39;spin down&#39;</span><span class="p">)]</span>

            <span class="k">elif</span> <span class="n">bs_projection</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;elements&quot;</span><span class="p">:</span>
                <span class="n">colors</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">,</span> <span class="s1">&#39;g&#39;</span><span class="p">]</span>
                <span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">el</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">elements</span><span class="p">):</span>
                    <span class="n">handles</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mlines</span><span class="o">.</span><span class="n">Line2D</span><span class="p">([],</span> <span class="p">[],</span>
                                                 <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
                                                 <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">idx</span><span class="p">],</span> <span class="n">label</span><span class="o">=</span><span class="n">el</span><span class="p">))</span>

            <span class="n">bs_ax</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">handles</span><span class="o">=</span><span class="n">handles</span><span class="p">,</span> <span class="n">fancybox</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                         <span class="n">prop</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;size&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">legend_fontsize</span><span class="p">,</span>
                               <span class="s1">&#39;family&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">font</span><span class="p">},</span> <span class="n">loc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">bs_legend</span><span class="p">)</span>

        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">bs_legend</span> <span class="ow">and</span> <span class="n">rgb_legend</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">elements</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_rb_line</span><span class="p">(</span><span class="n">bs_ax</span><span class="p">,</span> <span class="n">elements</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">elements</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                              <span class="n">loc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">bs_legend</span><span class="p">)</span>
            <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">elements</span><span class="p">)</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_rgb_triangle</span><span class="p">(</span><span class="n">bs_ax</span><span class="p">,</span> <span class="n">elements</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">elements</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">elements</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span>
                                   <span class="n">loc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">bs_legend</span><span class="p">)</span>

        <span class="c1"># add legend for DOS</span>
        <span class="k">if</span> <span class="n">dos</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">dos_legend</span><span class="p">:</span>
            <span class="n">dos_ax</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">fancybox</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">prop</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;size&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">legend_fontsize</span><span class="p">,</span>
                                               <span class="s1">&#39;family&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">font</span><span class="p">},</span>
                          <span class="n">loc</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dos_legend</span><span class="p">)</span>

        <span class="n">mplt</span><span class="o">.</span><span class="n">subplots_adjust</span><span class="p">(</span><span class="n">wspace</span><span class="o">=</span><span class="mf">0.1</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">mplt</span></div>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_rgbline</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span> <span class="n">red</span><span class="p">,</span> <span class="n">green</span><span class="p">,</span> <span class="n">blue</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">linestyles</span><span class="o">=</span><span class="s2">&quot;solid&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        An RGB colored line for plotting.</span>
<span class="sd">        creation of segments based on:</span>
<span class="sd">        http://nbviewer.ipython.org/urls/raw.github.com/dpsanders/matplotlib-examples/master/colorline.ipynb</span>
<span class="sd">        Args:</span>
<span class="sd">            ax: matplotlib axis</span>
<span class="sd">            k: x-axis data (k-points)</span>
<span class="sd">            e: y-axis data (energies)</span>
<span class="sd">            red: red data</span>
<span class="sd">            green: green data</span>
<span class="sd">            blue: blue data</span>
<span class="sd">            alpha: alpha values data</span>
<span class="sd">            linestyles: linestyle for plot (e.g., &quot;solid&quot; or &quot;dotted&quot;)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">from</span> <span class="nn">matplotlib.collections</span> <span class="kn">import</span> <span class="n">LineCollection</span>

        <span class="n">pts</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">k</span><span class="p">,</span> <span class="n">e</span><span class="p">])</span><span class="o">.</span><span class="n">T</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
        <span class="n">seg</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">concatenate</span><span class="p">([</span><span class="n">pts</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">pts</span><span class="p">[</span><span class="mi">1</span><span class="p">:]],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>

        <span class="n">nseg</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span>
        <span class="n">r</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.5</span> <span class="o">*</span> <span class="p">(</span><span class="n">red</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">red</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nseg</span><span class="p">)]</span>
        <span class="n">g</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.5</span> <span class="o">*</span> <span class="p">(</span><span class="n">green</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">green</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nseg</span><span class="p">)]</span>
        <span class="n">b</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.5</span> <span class="o">*</span> <span class="p">(</span><span class="n">blue</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">blue</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">])</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">nseg</span><span class="p">)]</span>
        <span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ones</span><span class="p">(</span><span class="n">nseg</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">float</span><span class="p">)</span> <span class="o">*</span> <span class="n">alpha</span>
        <span class="n">lc</span> <span class="o">=</span> <span class="n">LineCollection</span><span class="p">(</span><span class="n">seg</span><span class="p">,</span> <span class="n">colors</span><span class="o">=</span><span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">r</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">a</span><span class="p">)),</span>
                            <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">linestyles</span><span class="o">=</span><span class="n">linestyles</span><span class="p">)</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">add_collection</span><span class="p">(</span><span class="n">lc</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_get_colordata</span><span class="p">(</span><span class="n">bs</span><span class="p">,</span> <span class="n">elements</span><span class="p">,</span> <span class="n">bs_projection</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get color data, including projected band structures</span>
<span class="sd">        Args:</span>
<span class="sd">            bs: Bandstructure object</span>
<span class="sd">            elements: elements (in desired order) for setting to blue, red, green</span>
<span class="sd">            bs_projection: None for no projection, &quot;elements&quot; for element projection</span>

<span class="sd">        Returns:</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">contribs</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="n">bs_projection</span> <span class="ow">and</span> <span class="n">bs_projection</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;elements&quot;</span><span class="p">:</span>
            <span class="n">projections</span> <span class="o">=</span> <span class="n">bs</span><span class="o">.</span><span class="n">get_projection_on_elements</span><span class="p">()</span>

        <span class="k">for</span> <span class="n">spin</span> <span class="ow">in</span> <span class="p">(</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">,</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">spin</span> <span class="ow">in</span> <span class="n">bs</span><span class="o">.</span><span class="n">bands</span><span class="p">:</span>
                <span class="n">contribs</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">band_idx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">bs</span><span class="o">.</span><span class="n">nb_bands</span><span class="p">):</span>
                    <span class="n">colors</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="k">for</span> <span class="n">k_idx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bs</span><span class="o">.</span><span class="n">kpoints</span><span class="p">)):</span>
                        <span class="k">if</span> <span class="n">bs_projection</span> <span class="ow">and</span> <span class="n">bs_projection</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;elements&quot;</span><span class="p">:</span>
                            <span class="n">c</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
                            <span class="n">projs</span> <span class="o">=</span> <span class="n">projections</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="n">band_idx</span><span class="p">][</span><span class="n">k_idx</span><span class="p">]</span>
                            <span class="c1"># note: squared color interpolations are smoother</span>
                            <span class="c1"># see: https://youtu.be/LKnqECcg6Gw</span>
                            <span class="n">projs</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span>
                                <span class="p">[(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="o">**</span> <span class="mi">2</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">projs</span><span class="o">.</span><span class="n">items</span><span class="p">()])</span>
                            <span class="n">total</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="n">projs</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
                            <span class="k">if</span> <span class="n">total</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                                <span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">elements</span><span class="p">):</span>
                                    <span class="n">c</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">projs</span><span class="p">[</span>
                                                           <span class="n">e</span><span class="p">]</span> <span class="o">/</span> <span class="n">total</span><span class="p">)</span>  <span class="c1"># min is to handle round errors</span>

                            <span class="n">c</span> <span class="o">=</span> <span class="p">[</span><span class="n">c</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">c</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span>
                                 <span class="n">c</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>  <span class="c1"># prefer blue, then red, then green</span>

                        <span class="k">else</span><span class="p">:</span>
                            <span class="n">c</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span> <span class="k">if</span> <span class="n">spin</span> <span class="o">==</span> <span class="n">Spin</span><span class="o">.</span><span class="n">up</span> \
                                <span class="k">else</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span>
                                      <span class="mi">1</span><span class="p">]</span>  <span class="c1"># black for spin up, blue for spin down</span>

                        <span class="n">colors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>

                    <span class="n">contribs</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">colors</span><span class="p">)</span>
                <span class="n">contribs</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">contribs</span><span class="p">[</span><span class="n">spin</span><span class="p">])</span>

        <span class="k">return</span> <span class="n">contribs</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_rgb_triangle</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">r_label</span><span class="p">,</span> <span class="n">g_label</span><span class="p">,</span> <span class="n">b_label</span><span class="p">,</span> <span class="n">loc</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Draw an RGB triangle legend on the desired axis</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">loc</span> <span class="ow">not</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">11</span><span class="p">):</span>
            <span class="n">loc</span> <span class="o">=</span> <span class="mi">2</span>

        <span class="kn">from</span> <span class="nn">mpl_toolkits.axes_grid1.inset_locator</span> <span class="kn">import</span> <span class="n">inset_axes</span>
        <span class="n">inset_ax</span> <span class="o">=</span> <span class="n">inset_axes</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">loc</span><span class="o">=</span><span class="n">loc</span><span class="p">)</span>
        <span class="n">mesh</span> <span class="o">=</span> <span class="mi">35</span>
        <span class="n">x</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">y</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">color</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">mesh</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">g</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">mesh</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">mesh</span><span class="p">):</span>
                    <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">r</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">b</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">g</span> <span class="o">==</span> <span class="mi">0</span><span class="p">):</span>
                        <span class="n">r1</span> <span class="o">=</span> <span class="n">r</span> <span class="o">/</span> <span class="p">(</span><span class="n">r</span> <span class="o">+</span> <span class="n">g</span> <span class="o">+</span> <span class="n">b</span><span class="p">)</span>
                        <span class="n">g1</span> <span class="o">=</span> <span class="n">g</span> <span class="o">/</span> <span class="p">(</span><span class="n">r</span> <span class="o">+</span> <span class="n">g</span> <span class="o">+</span> <span class="n">b</span><span class="p">)</span>
                        <span class="n">b1</span> <span class="o">=</span> <span class="n">b</span> <span class="o">/</span> <span class="p">(</span><span class="n">r</span> <span class="o">+</span> <span class="n">g</span> <span class="o">+</span> <span class="n">b</span><span class="p">)</span>
                        <span class="n">x</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.33</span> <span class="o">*</span> <span class="p">(</span><span class="mf">2.</span> <span class="o">*</span> <span class="n">g1</span> <span class="o">+</span> <span class="n">r1</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">r1</span> <span class="o">+</span> <span class="n">b1</span> <span class="o">+</span> <span class="n">g1</span><span class="p">))</span>
                        <span class="n">y</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">0.33</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="o">*</span> <span class="n">r1</span> <span class="o">/</span> <span class="p">(</span><span class="n">r1</span> <span class="o">+</span> <span class="n">b1</span> <span class="o">+</span> <span class="n">g1</span><span class="p">))</span>
                        <span class="n">rc</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">r</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">/</span> <span class="p">(</span><span class="n">r</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">+</span> <span class="n">g</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">+</span> <span class="n">b</span> <span class="o">**</span> <span class="mi">2</span><span class="p">))</span>
                        <span class="n">gc</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">g</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">/</span> <span class="p">(</span><span class="n">r</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">+</span> <span class="n">g</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">+</span> <span class="n">b</span> <span class="o">**</span> <span class="mi">2</span><span class="p">))</span>
                        <span class="n">bc</span> <span class="o">=</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">b</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">/</span> <span class="p">(</span><span class="n">r</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">+</span> <span class="n">g</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">+</span> <span class="n">b</span> <span class="o">**</span> <span class="mi">2</span><span class="p">))</span>
                        <span class="n">color</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">rc</span><span class="p">,</span> <span class="n">gc</span><span class="p">,</span> <span class="n">bc</span><span class="p">])</span>

        <span class="c1"># x = [n + 0.25 for n in x]  # nudge x coordinates</span>
        <span class="c1"># y = [n + (max_y - 1) for n in y]  # shift y coordinates to top</span>
        <span class="c1"># plot the triangle</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="mi">7</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;.&#39;</span><span class="p">,</span> <span class="n">edgecolor</span><span class="o">=</span><span class="n">color</span><span class="p">)</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">([</span><span class="o">-</span><span class="mf">0.35</span><span class="p">,</span> <span class="mf">1.00</span><span class="p">])</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">([</span><span class="o">-</span><span class="mf">0.35</span><span class="p">,</span> <span class="mf">1.00</span><span class="p">])</span>

        <span class="c1"># add the labels</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="mf">0.70</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.2</span><span class="p">,</span> <span class="n">g_label</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">13</span><span class="p">,</span>
                      <span class="n">family</span><span class="o">=</span><span class="s1">&#39;Times New Roman&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
                      <span class="n">horizontalalignment</span><span class="o">=</span><span class="s1">&#39;left&#39;</span><span class="p">)</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="mf">0.325</span><span class="p">,</span> <span class="mf">0.70</span><span class="p">,</span> <span class="n">r_label</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">13</span><span class="p">,</span>
                      <span class="n">family</span><span class="o">=</span><span class="s1">&#39;Times New Roman&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
                      <span class="n">horizontalalignment</span><span class="o">=</span><span class="s1">&#39;center&#39;</span><span class="p">)</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="o">-</span><span class="mf">0.05</span><span class="p">,</span> <span class="o">-</span><span class="mf">0.2</span><span class="p">,</span> <span class="n">b_label</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">13</span><span class="p">,</span>
                      <span class="n">family</span><span class="o">=</span><span class="s1">&#39;Times New Roman&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
                      <span class="n">horizontalalignment</span><span class="o">=</span><span class="s1">&#39;right&#39;</span><span class="p">)</span>

        <span class="n">inset_ax</span><span class="o">.</span><span class="n">get_xaxis</span><span class="p">()</span><span class="o">.</span><span class="n">set_visible</span><span class="p">(</span><span class="kc">False</span><span class="p">)</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">get_yaxis</span><span class="p">()</span><span class="o">.</span><span class="n">set_visible</span><span class="p">(</span><span class="kc">False</span><span class="p">)</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_rb_line</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">r_label</span><span class="p">,</span> <span class="n">b_label</span><span class="p">,</span> <span class="n">loc</span><span class="p">):</span>
        <span class="c1"># Draw an rb bar legend on the desired axis</span>

        <span class="k">if</span> <span class="n">loc</span> <span class="ow">not</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">11</span><span class="p">):</span>
            <span class="n">loc</span> <span class="o">=</span> <span class="mi">2</span>
        <span class="kn">from</span> <span class="nn">mpl_toolkits.axes_grid1.inset_locator</span> <span class="kn">import</span> <span class="n">inset_axes</span>
        <span class="n">inset_ax</span> <span class="o">=</span> <span class="n">inset_axes</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mf">1.2</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mf">0.4</span><span class="p">,</span> <span class="n">loc</span><span class="o">=</span><span class="n">loc</span><span class="p">)</span>

        <span class="n">x</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">y</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">color</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1000</span><span class="p">):</span>
            <span class="n">x</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">i</span> <span class="o">/</span> <span class="mf">1800.</span> <span class="o">+</span> <span class="mf">0.55</span><span class="p">)</span>
            <span class="n">y</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
            <span class="n">color</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">c</span><span class="p">)</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span>
                          <span class="p">[</span><span class="mi">1</span> <span class="o">-</span> <span class="p">(</span><span class="n">i</span> <span class="o">/</span> <span class="mi">1000</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="p">(</span><span class="n">i</span> <span class="o">/</span> <span class="mi">1000</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span><span class="p">]])</span>

        <span class="c1"># plot the bar</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">s</span><span class="o">=</span><span class="mf">250.</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="n">c</span><span class="o">=</span><span class="n">color</span><span class="p">)</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">([</span><span class="o">-</span><span class="mf">0.1</span><span class="p">,</span> <span class="mf">1.7</span><span class="p">])</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="mf">1.35</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">b_label</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">13</span><span class="p">,</span>
                      <span class="n">family</span><span class="o">=</span><span class="s1">&#39;Times New Roman&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
                      <span class="n">horizontalalignment</span><span class="o">=</span><span class="s2">&quot;left&quot;</span><span class="p">,</span> <span class="n">verticalalignment</span><span class="o">=</span><span class="s2">&quot;center&quot;</span><span class="p">)</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="mf">0.30</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">r_label</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">13</span><span class="p">,</span>
                      <span class="n">family</span><span class="o">=</span><span class="s1">&#39;Times New Roman&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
                      <span class="n">horizontalalignment</span><span class="o">=</span><span class="s2">&quot;right&quot;</span><span class="p">,</span> <span class="n">verticalalignment</span><span class="o">=</span><span class="s2">&quot;center&quot;</span><span class="p">)</span>

        <span class="n">inset_ax</span><span class="o">.</span><span class="n">get_xaxis</span><span class="p">()</span><span class="o">.</span><span class="n">set_visible</span><span class="p">(</span><span class="kc">False</span><span class="p">)</span>
        <span class="n">inset_ax</span><span class="o">.</span><span class="n">get_yaxis</span><span class="p">()</span><span class="o">.</span><span class="n">set_visible</span><span class="p">(</span><span class="kc">False</span><span class="p">)</span></div>


<div class="viewcode-block" id="BoltztrapPlotter"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter">[docs]</a><span class="k">class</span> <span class="nc">BoltztrapPlotter</span><span class="p">:</span>
    <span class="c1"># TODO: We need a unittest for this. Come on folks.</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    class containing methods to plot the data from Boltztrap.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">bz</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            bz: a BoltztrapAnalyzer object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span> <span class="o">=</span> <span class="n">bz</span>

    <span class="k">def</span> <span class="nf">_plot_doping</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temp</span><span class="p">):</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">limit</span> <span class="o">=</span> <span class="mf">2.21e15</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">axvline</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span>
                        <span class="n">linestyle</span><span class="o">=</span><span class="s2">&quot;--&quot;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mf">0.01</span><span class="p">,</span>
                     <span class="n">limit</span><span class="p">,</span>
                     <span class="s2">&quot;$n$=10$^{&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span>
                         <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]))</span> <span class="o">+</span> <span class="s2">&quot;}$&quot;</span><span class="p">,</span>
                     <span class="n">color</span><span class="o">=</span><span class="s1">&#39;b&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">axvline</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span>
                        <span class="n">linestyle</span><span class="o">=</span><span class="s2">&quot;--&quot;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mf">0.01</span><span class="p">,</span>
                     <span class="n">limit</span><span class="p">,</span>
                     <span class="s2">&quot;$n$=10$^{&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]))</span>
                     <span class="o">+</span> <span class="s2">&quot;}$&quot;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;b&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">axvline</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;p&#39;</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span>
                        <span class="n">linestyle</span><span class="o">=</span><span class="s2">&quot;--&quot;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;p&#39;</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mf">0.01</span><span class="p">,</span>
                     <span class="n">limit</span><span class="p">,</span>
                     <span class="s2">&quot;$p$=10$^{&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span>
                         <span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="s1">&#39;p&#39;</span><span class="p">][</span><span class="mi">0</span><span class="p">]))</span> <span class="o">+</span> <span class="s2">&quot;}$&quot;</span><span class="p">,</span>
                     <span class="n">color</span><span class="o">=</span><span class="s1">&#39;b&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">axvline</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;p&#39;</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span>
                        <span class="n">linestyle</span><span class="o">=</span><span class="s2">&quot;--&quot;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;p&#39;</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mf">0.01</span><span class="p">,</span>
                     <span class="n">limit</span><span class="p">,</span> <span class="s2">&quot;$p$=10$^{&quot;</span> <span class="o">+</span>
                     <span class="nb">str</span><span class="p">(</span><span class="n">math</span><span class="o">.</span><span class="n">log10</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="s1">&#39;p&#39;</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">]))</span> <span class="o">+</span> <span class="s2">&quot;}$&quot;</span><span class="p">,</span>
                     <span class="n">color</span><span class="o">=</span><span class="s1">&#39;b&#39;</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_plot_bg_limits</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">axvline</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">axvline</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">gap</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;k&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>

<div class="viewcode-block" id="BoltztrapPlotter.plot_seebeck_eff_mass_mu"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_seebeck_eff_mass_mu">[docs]</a>    <span class="k">def</span> <span class="nf">plot_seebeck_eff_mass_mu</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temps</span><span class="o">=</span><span class="p">[</span><span class="mi">300</span><span class="p">],</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">,</span>
                                 <span class="n">Lambda</span><span class="o">=</span><span class="mf">0.5</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot respect to the chemical potential of the Seebeck effective mass</span>
<span class="sd">        calculated as explained in Ref.</span>
<span class="sd">        Gibbs, Z. M. et al., Effective mass and fermi surface complexity factor</span>
<span class="sd">        from ab initio band structure calculations.</span>
<span class="sd">        npj Computational Materials 3, 8 (2017).</span>

<span class="sd">        Args:</span>
<span class="sd">            output: &#39;average&#39; returns the seebeck effective mass calculated</span>
<span class="sd">                using the average of the three diagonal components of the</span>
<span class="sd">                seebeck tensor. &#39;tensor&#39; returns the seebeck effective mass</span>
<span class="sd">                respect to the three diagonal components of the seebeck tensor.</span>
<span class="sd">            temps:  list of temperatures of calculated seebeck.</span>
<span class="sd">            Lambda: fitting parameter used to model the scattering (0.5 means</span>
<span class="sd">                constant relaxation time).</span>
<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">T</span> <span class="ow">in</span> <span class="n">temps</span><span class="p">:</span>
            <span class="n">sbk_mass</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_seebeck_eff_mass</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="n">output</span><span class="p">,</span> <span class="n">temp</span><span class="o">=</span><span class="n">T</span><span class="p">,</span>
                                                     <span class="n">Lambda</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
            <span class="c1"># remove noise inside the gap</span>
            <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;p&#39;</span><span class="p">][</span><span class="n">T</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">stop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">][</span><span class="n">T</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">mu_steps_1</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">mu_steps_2</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">sbk_mass_1</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">sbk_mass_2</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">mu</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_steps</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">mu</span> <span class="o">&lt;=</span> <span class="n">start</span><span class="p">:</span>
                    <span class="n">mu_steps_1</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span>
                    <span class="n">sbk_mass_1</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">sbk_mass</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                <span class="k">elif</span> <span class="n">mu</span> <span class="o">&gt;=</span> <span class="n">stop</span><span class="p">:</span>
                    <span class="n">mu_steps_2</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span>
                    <span class="n">sbk_mass_2</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">sbk_mass</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>

            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">mu_steps_1</span><span class="p">,</span> <span class="n">sbk_mass_1</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">T</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;K&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">mu_steps_2</span><span class="p">,</span> <span class="n">sbk_mass_2</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_c</span><span class="p">(</span><span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">get_c</span><span class="p">())</span>
            <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;tensor&#39;</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">set_c</span><span class="p">(</span><span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">get_c</span><span class="p">())</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">4</span><span class="p">]</span><span class="o">.</span><span class="n">set_c</span><span class="p">(</span><span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">get_c</span><span class="p">())</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">5</span><span class="p">]</span><span class="o">.</span><span class="n">set_c</span><span class="p">(</span><span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">get_c</span><span class="p">())</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s2">&quot;E-E$_f$ (eV)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Seebeck effective mass&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;tensor&#39;</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">([</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">T</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;K&#39;</span> <span class="k">for</span> <span class="n">T</span> <span class="ow">in</span> <span class="n">temps</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span>
                        <span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">,</span> <span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="s1">&#39;z&#39;</span><span class="p">)],</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_complexity_factor_mu"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_complexity_factor_mu">[docs]</a>    <span class="k">def</span> <span class="nf">plot_complexity_factor_mu</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temps</span><span class="o">=</span><span class="p">[</span><span class="mi">300</span><span class="p">],</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">,</span>
                                  <span class="n">Lambda</span><span class="o">=</span><span class="mf">0.5</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot respect to the chemical potential of the Fermi surface complexity</span>
<span class="sd">        factor calculated as explained in Ref.</span>
<span class="sd">        Gibbs, Z. M. et al., Effective mass and fermi surface complexity factor</span>
<span class="sd">        from ab initio band structure calculations.</span>
<span class="sd">        npj Computational Materials 3, 8 (2017).</span>

<span class="sd">        Args:</span>
<span class="sd">            output: &#39;average&#39; returns the complexity factor calculated using the average</span>
<span class="sd">                    of the three diagonal components of the seebeck and conductivity tensors.</span>
<span class="sd">                    &#39;tensor&#39; returns the complexity factor respect to the three</span>
<span class="sd">                    diagonal components of seebeck and conductivity tensors.</span>
<span class="sd">            temps:  list of temperatures of calculated seebeck and conductivity.</span>
<span class="sd">            Lambda: fitting parameter used to model the scattering (0.5 means constant</span>
<span class="sd">                    relaxation time).</span>
<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">T</span> <span class="ow">in</span> <span class="n">temps</span><span class="p">:</span>
            <span class="n">cmplx_fact</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_complexity_factor</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="n">output</span><span class="p">,</span> <span class="n">temp</span><span class="o">=</span><span class="n">T</span><span class="p">,</span>
                                                        <span class="n">Lambda</span><span class="o">=</span><span class="n">Lambda</span><span class="p">)</span>
            <span class="n">start</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;p&#39;</span><span class="p">][</span><span class="n">T</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">stop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">][</span><span class="n">T</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
            <span class="n">mu_steps_1</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">mu_steps_2</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">cmplx_fact_1</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">cmplx_fact_2</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">mu</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_steps</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">mu</span> <span class="o">&lt;=</span> <span class="n">start</span><span class="p">:</span>
                    <span class="n">mu_steps_1</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span>
                    <span class="n">cmplx_fact_1</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cmplx_fact</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
                <span class="k">elif</span> <span class="n">mu</span> <span class="o">&gt;=</span> <span class="n">stop</span><span class="p">:</span>
                    <span class="n">mu_steps_2</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span>
                    <span class="n">cmplx_fact_2</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cmplx_fact</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>

            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">mu_steps_1</span><span class="p">,</span> <span class="n">cmplx_fact_1</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">T</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;K&#39;</span><span class="p">,</span>
                     <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">mu_steps_2</span><span class="p">,</span> <span class="n">cmplx_fact_2</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">set_c</span><span class="p">(</span><span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">get_c</span><span class="p">())</span>
            <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;tensor&#39;</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">set_c</span><span class="p">(</span><span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">get_c</span><span class="p">())</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">4</span><span class="p">]</span><span class="o">.</span><span class="n">set_c</span><span class="p">(</span><span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">get_c</span><span class="p">())</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">5</span><span class="p">]</span><span class="o">.</span><span class="n">set_c</span><span class="p">(</span><span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_lines</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">get_c</span><span class="p">())</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s2">&quot;E-E$_f$ (eV)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Complexity Factor&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;tensor&#39;</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">([</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;_&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">T</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;K&#39;</span> <span class="k">for</span> <span class="n">T</span> <span class="ow">in</span> <span class="n">temps</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span>
                        <span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">,</span> <span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="s1">&#39;z&#39;</span><span class="p">)],</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_seebeck_mu"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_seebeck_mu">[docs]</a>    <span class="k">def</span> <span class="nf">plot_seebeck_mu</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temp</span><span class="o">=</span><span class="mi">600</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;eig&#39;</span><span class="p">,</span> <span class="n">xlim</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the seebeck coefficient in function of Fermi level</span>

<span class="sd">        Args:</span>
<span class="sd">            temp:</span>
<span class="sd">                the temperature</span>
<span class="sd">            xlim:</span>
<span class="sd">                a list of min and max fermi energy by default (0, and band gap)</span>
<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">))</span>
        <span class="n">seebeck</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_seebeck</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="n">output</span><span class="p">,</span> <span class="n">doping_levels</span><span class="o">=</span><span class="kc">False</span><span class="p">)[</span>
            <span class="n">temp</span><span class="p">]</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_steps</span><span class="p">,</span> <span class="n">seebeck</span><span class="p">,</span>
                 <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_bg_limits</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_doping</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eig&#39;</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">([</span><span class="s1">&#39;S$_1$&#39;</span><span class="p">,</span> <span class="s1">&#39;S$_2$&#39;</span><span class="p">,</span> <span class="s1">&#39;S$_3$&#39;</span><span class="p">])</span>
        <span class="k">if</span> <span class="n">xlim</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">gap</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="n">xlim</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">xlim</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Seebeck </span><span class="se">\n</span><span class="s2"> coefficient  ($</span><span class="se">\\</span><span class="s2">mu$V/K)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s2">&quot;E-E$_f$ (eV)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_conductivity_mu"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_conductivity_mu">[docs]</a>    <span class="k">def</span> <span class="nf">plot_conductivity_mu</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temp</span><span class="o">=</span><span class="mi">600</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;eig&#39;</span><span class="p">,</span>
                             <span class="n">relaxation_time</span><span class="o">=</span><span class="mf">1e-14</span><span class="p">,</span> <span class="n">xlim</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the conductivity in function of Fermi level. Semi-log plot</span>

<span class="sd">        Args:</span>
<span class="sd">            temp: the temperature</span>
<span class="sd">            xlim: a list of min and max fermi energy by default (0, and band</span>
<span class="sd">                gap)</span>
<span class="sd">            tau: A relaxation time in s. By default none and the plot is by</span>
<span class="sd">               units of relaxation time</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="n">cond</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_conductivity</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                         <span class="n">output</span><span class="o">=</span><span class="n">output</span><span class="p">,</span> <span class="n">doping_levels</span><span class="o">=</span><span class="kc">False</span><span class="p">)[</span>
            <span class="n">temp</span><span class="p">]</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">))</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">semilogy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_steps</span><span class="p">,</span> <span class="n">cond</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_bg_limits</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_doping</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eig&#39;</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">([</span><span class="s1">&#39;$</span><span class="se">\\</span><span class="s1">Sigma_1$&#39;</span><span class="p">,</span> <span class="s1">&#39;$</span><span class="se">\\</span><span class="s1">Sigma_2$&#39;</span><span class="p">,</span> <span class="s1">&#39;$</span><span class="se">\\</span><span class="s1">Sigma_3$&#39;</span><span class="p">])</span>
        <span class="k">if</span> <span class="n">xlim</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">gap</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="n">xlim</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">([</span><span class="mf">1e13</span> <span class="o">*</span> <span class="n">relaxation_time</span><span class="p">,</span> <span class="mf">1e20</span> <span class="o">*</span> <span class="n">relaxation_time</span><span class="p">])</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;conductivity,</span><span class="se">\n</span><span class="s2"> $</span><span class="se">\\</span><span class="s2">Sigma$ (1/($</span><span class="se">\\</span><span class="s2">Omega$ m))&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s2">&quot;E-E$_f$ (eV)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_power_factor_mu"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_power_factor_mu">[docs]</a>    <span class="k">def</span> <span class="nf">plot_power_factor_mu</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temp</span><span class="o">=</span><span class="mi">600</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;eig&#39;</span><span class="p">,</span>
                             <span class="n">relaxation_time</span><span class="o">=</span><span class="mf">1e-14</span><span class="p">,</span> <span class="n">xlim</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the power factor in function of Fermi level. Semi-log plot</span>

<span class="sd">        Args:</span>
<span class="sd">            temp: the temperature</span>
<span class="sd">            xlim: a list of min and max fermi energy by default (0, and band</span>
<span class="sd">                gap)</span>
<span class="sd">            tau: A relaxation time in s. By default none and the plot is by</span>
<span class="sd">               units of relaxation time</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">))</span>
        <span class="n">pf</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_power_factor</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                       <span class="n">output</span><span class="o">=</span><span class="n">output</span><span class="p">,</span> <span class="n">doping_levels</span><span class="o">=</span><span class="kc">False</span><span class="p">)[</span>
            <span class="n">temp</span><span class="p">]</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">semilogy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_steps</span><span class="p">,</span> <span class="n">pf</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_bg_limits</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_doping</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eig&#39;</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">([</span><span class="s1">&#39;PF$_1$&#39;</span><span class="p">,</span> <span class="s1">&#39;PF$_2$&#39;</span><span class="p">,</span> <span class="s1">&#39;PF$_3$&#39;</span><span class="p">])</span>
        <span class="k">if</span> <span class="n">xlim</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">gap</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="n">xlim</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Power factor, ($</span><span class="se">\\</span><span class="s2">mu$W/(mK$^2$))&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s2">&quot;E-E$_f$ (eV)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_zt_mu"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_zt_mu">[docs]</a>    <span class="k">def</span> <span class="nf">plot_zt_mu</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temp</span><span class="o">=</span><span class="mi">600</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;eig&#39;</span><span class="p">,</span> <span class="n">relaxation_time</span><span class="o">=</span><span class="mf">1e-14</span><span class="p">,</span>
                   <span class="n">xlim</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the ZT in function of Fermi level.</span>

<span class="sd">        Args:</span>
<span class="sd">            temp: the temperature</span>
<span class="sd">            xlim: a list of min and max fermi energy by default (0, and band</span>
<span class="sd">                gap)</span>
<span class="sd">            tau: A relaxation time in s. By default none and the plot is by</span>
<span class="sd">               units of relaxation time</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">9</span><span class="p">,</span> <span class="mi">7</span><span class="p">))</span>
        <span class="n">zt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_zt</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="n">output</span><span class="p">,</span>
                             <span class="n">doping_levels</span><span class="o">=</span><span class="kc">False</span><span class="p">)[</span><span class="n">temp</span><span class="p">]</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_steps</span><span class="p">,</span> <span class="n">zt</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_bg_limits</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_doping</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eig&#39;</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">([</span><span class="s1">&#39;ZT$_1$&#39;</span><span class="p">,</span> <span class="s1">&#39;ZT$_2$&#39;</span><span class="p">,</span> <span class="s1">&#39;ZT$_3$&#39;</span><span class="p">])</span>
        <span class="k">if</span> <span class="n">xlim</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">gap</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="n">xlim</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;ZT&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s2">&quot;E-E$_f$ (eV)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_seebeck_temp"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_seebeck_temp">[docs]</a>    <span class="k">def</span> <span class="nf">plot_seebeck_temp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">doping</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the Seebeck coefficient in function of temperature for different</span>
<span class="sd">        doping levels.</span>

<span class="sd">        Args:</span>
<span class="sd">            dopings: the default &#39;all&#39; plots all the doping levels in the analyzer.</span>
<span class="sd">                     Specify a list of doping levels if you want to plot only some.</span>
<span class="sd">            output: with &#39;average&#39; you get an average of the three directions</span>
<span class="sd">                    with &#39;eigs&#39; you get all the three directions.</span>
<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">sbk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_seebeck</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
            <span class="n">sbk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_seebeck</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="s1">&#39;eigs&#39;</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="mi">14</span><span class="p">))</span>
        <span class="n">tlist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">sbk</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
        <span class="n">doping</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span> <span class="k">if</span> <span class="n">doping</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span> <span class="k">else</span> <span class="n">doping</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">]):</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span> <span class="o">+</span> <span class="n">i</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">dop</span> <span class="ow">in</span> <span class="n">doping</span><span class="p">:</span>
                <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span>
                <span class="n">sbk_temp</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">temp</span> <span class="ow">in</span> <span class="n">tlist</span><span class="p">:</span>
                    <span class="n">sbk_temp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">sbk</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="n">d</span><span class="p">])</span>
                <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tlist</span><span class="p">,</span> <span class="n">sbk_temp</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                             <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; $cm^{-3}$&#39;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tlist</span><span class="p">,</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">sbk_temp</span><span class="p">)[</span><span class="n">xyz</span><span class="p">],</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                                 <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; $cm^{-3}$&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">dt</span> <span class="o">+</span> <span class="s1">&#39;-type&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Seebeck </span><span class="se">\n</span><span class="s2"> coefficient  ($</span><span class="se">\\</span><span class="s2">mu$V/K)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Temperature (K)&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>

            <span class="n">p</span> <span class="o">=</span> <span class="s1">&#39;lower right&#39;</span> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="n">p</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_conductivity_temp"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_conductivity_temp">[docs]</a>    <span class="k">def</span> <span class="nf">plot_conductivity_temp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">doping</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">,</span>
                               <span class="n">relaxation_time</span><span class="o">=</span><span class="mf">1e-14</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the conductivity in function of temperature for different doping levels.</span>

<span class="sd">        Args:</span>
<span class="sd">            dopings: the default &#39;all&#39; plots all the doping levels in the analyzer.</span>
<span class="sd">                     Specify a list of doping levels if you want to plot only some.</span>
<span class="sd">            output: with &#39;average&#39; you get an average of the three directions</span>
<span class="sd">                    with &#39;eigs&#39; you get all the three directions.</span>
<span class="sd">            relaxation_time: specify a constant relaxation time value</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>

        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">cond</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_conductivity</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                             <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
            <span class="n">cond</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_conductivity</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                             <span class="n">output</span><span class="o">=</span><span class="s1">&#39;eigs&#39;</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="mi">14</span><span class="p">))</span>
        <span class="n">tlist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">cond</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
        <span class="n">doping</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span> <span class="k">if</span> <span class="n">doping</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span> <span class="k">else</span> <span class="n">doping</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">]):</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span> <span class="o">+</span> <span class="n">i</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">dop</span> <span class="ow">in</span> <span class="n">doping</span><span class="p">:</span>
                <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span>
                <span class="n">cond_temp</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">temp</span> <span class="ow">in</span> <span class="n">tlist</span><span class="p">:</span>
                    <span class="n">cond_temp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cond</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="n">d</span><span class="p">])</span>
                <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tlist</span><span class="p">,</span> <span class="n">cond_temp</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                             <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; $cm^{-3}$&#39;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tlist</span><span class="p">,</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">cond_temp</span><span class="p">)[</span><span class="n">xyz</span><span class="p">],</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                                 <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; $cm^{-3}$&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">dt</span> <span class="o">+</span> <span class="s1">&#39;-type&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;conductivity $</span><span class="se">\\</span><span class="s2">sigma$ (1/($</span><span class="se">\\</span><span class="s2">Omega$ m))&quot;</span><span class="p">,</span>
                           <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Temperature (K)&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>

            <span class="n">p</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>  <span class="c1"># &#39;lower right&#39; if i == 0 else &#39;&#39;</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="n">p</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ticklabel_format</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s1">&#39;sci&#39;</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">scilimits</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_power_factor_temp"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_power_factor_temp">[docs]</a>    <span class="k">def</span> <span class="nf">plot_power_factor_temp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">doping</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">,</span>
                               <span class="n">relaxation_time</span><span class="o">=</span><span class="mf">1e-14</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the Power Factor in function of temperature for different doping levels.</span>

<span class="sd">        Args:</span>
<span class="sd">            dopings: the default &#39;all&#39; plots all the doping levels in the analyzer.</span>
<span class="sd">                     Specify a list of doping levels if you want to plot only some.</span>
<span class="sd">            output: with &#39;average&#39; you get an average of the three directions</span>
<span class="sd">                    with &#39;eigs&#39; you get all the three directions.</span>
<span class="sd">            relaxation_time: specify a constant relaxation time value</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">pf</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_power_factor</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                           <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
            <span class="n">pf</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_power_factor</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                           <span class="n">output</span><span class="o">=</span><span class="s1">&#39;eigs&#39;</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="mi">14</span><span class="p">))</span>
        <span class="n">tlist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">pf</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
        <span class="n">doping</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span> <span class="k">if</span> <span class="n">doping</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span> <span class="k">else</span> <span class="n">doping</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">]):</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span> <span class="o">+</span> <span class="n">i</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">dop</span> <span class="ow">in</span> <span class="n">doping</span><span class="p">:</span>
                <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span>
                <span class="n">pf_temp</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">temp</span> <span class="ow">in</span> <span class="n">tlist</span><span class="p">:</span>
                    <span class="n">pf_temp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pf</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="n">d</span><span class="p">])</span>
                <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tlist</span><span class="p">,</span> <span class="n">pf_temp</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                             <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; $cm^{-3}$&#39;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tlist</span><span class="p">,</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">pf_temp</span><span class="p">)[</span><span class="n">xyz</span><span class="p">],</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                                 <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; $cm^{-3}$&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">dt</span> <span class="o">+</span> <span class="s1">&#39;-type&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Power Factor ($</span><span class="se">\\</span><span class="s2">mu$W/(mK$^2$))&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Temperature (K)&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>

            <span class="n">p</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>  <span class="c1"># &#39;lower right&#39; if i == 0 else &#39;&#39;</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="n">p</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ticklabel_format</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s1">&#39;sci&#39;</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">scilimits</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_zt_temp"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_zt_temp">[docs]</a>    <span class="k">def</span> <span class="nf">plot_zt_temp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">doping</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">,</span>
                     <span class="n">relaxation_time</span><span class="o">=</span><span class="mf">1e-14</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the figure of merit zT in function of temperature for different doping levels.</span>

<span class="sd">        Args:</span>
<span class="sd">            dopings: the default &#39;all&#39; plots all the doping levels in the analyzer.</span>
<span class="sd">                     Specify a list of doping levels if you want to plot only some.</span>
<span class="sd">            output: with &#39;average&#39; you get an average of the three directions</span>
<span class="sd">                    with &#39;eigs&#39; you get all the three directions.</span>
<span class="sd">            relaxation_time: specify a constant relaxation time value</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">zt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_zt</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                 <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
            <span class="n">zt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_zt</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;eigs&#39;</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="mi">14</span><span class="p">))</span>
        <span class="n">tlist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">zt</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
        <span class="n">doping</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span> <span class="k">if</span> <span class="n">doping</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span> <span class="k">else</span> <span class="n">doping</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">]):</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span> <span class="o">+</span> <span class="n">i</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">dop</span> <span class="ow">in</span> <span class="n">doping</span><span class="p">:</span>
                <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span>
                <span class="n">zt_temp</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">temp</span> <span class="ow">in</span> <span class="n">tlist</span><span class="p">:</span>
                    <span class="n">zt_temp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">zt</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="n">d</span><span class="p">])</span>
                <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tlist</span><span class="p">,</span> <span class="n">zt_temp</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                             <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; $cm^{-3}$&#39;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tlist</span><span class="p">,</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">zt_temp</span><span class="p">)[</span><span class="n">xyz</span><span class="p">],</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                                 <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; $cm^{-3}$&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">dt</span> <span class="o">+</span> <span class="s1">&#39;-type&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;zT&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Temperature (K)&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>

            <span class="n">p</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>  <span class="c1"># &#39;lower right&#39; if i == 0 else &#39;&#39;</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="n">p</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_eff_mass_temp"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_eff_mass_temp">[docs]</a>    <span class="k">def</span> <span class="nf">plot_eff_mass_temp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">doping</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the average effective mass in function of temperature</span>
<span class="sd">        for different doping levels.</span>

<span class="sd">        Args:</span>
<span class="sd">            dopings: the default &#39;all&#39; plots all the doping levels in the analyzer.</span>
<span class="sd">                     Specify a list of doping levels if you want to plot only some.</span>
<span class="sd">            output: with &#39;average&#39; you get an average of the three directions</span>
<span class="sd">                    with &#39;eigs&#39; you get all the three directions.</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">em</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_average_eff_mass</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
            <span class="n">em</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_average_eff_mass</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="s1">&#39;eigs&#39;</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="mi">14</span><span class="p">))</span>
        <span class="n">tlist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">em</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
        <span class="n">doping</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span> <span class="k">if</span> <span class="n">doping</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span> <span class="k">else</span> <span class="n">doping</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">]):</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span> <span class="o">+</span> <span class="n">i</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">dop</span> <span class="ow">in</span> <span class="n">doping</span><span class="p">:</span>
                <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span>
                <span class="n">em_temp</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">temp</span> <span class="ow">in</span> <span class="n">tlist</span><span class="p">:</span>
                    <span class="n">em_temp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">em</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">][</span><span class="n">d</span><span class="p">])</span>
                <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tlist</span><span class="p">,</span> <span class="n">em_temp</span><span class="p">,</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                             <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; $cm^{-3}$&#39;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tlist</span><span class="p">,</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">em_temp</span><span class="p">)[</span><span class="n">xyz</span><span class="p">],</span> <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                                 <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">dop</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; $cm^{-3}$&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">dt</span> <span class="o">+</span> <span class="s1">&#39;-type&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Effective mass (m$_e$)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Temperature (K)&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>

            <span class="n">p</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>  <span class="c1"># &#39;lower right&#39; if i == 0 else &#39;&#39;</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="n">p</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_seebeck_dop"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_seebeck_dop">[docs]</a>    <span class="k">def</span> <span class="nf">plot_seebeck_dop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temps</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the Seebeck in function of doping levels for different temperatures.</span>

<span class="sd">        Args:</span>
<span class="sd">            temps: the default &#39;all&#39; plots all the temperatures in the analyzer.</span>
<span class="sd">                   Specify a list of temperatures if you want to plot only some.</span>
<span class="sd">            output: with &#39;average&#39; you get an average of the three directions</span>
<span class="sd">                    with &#39;eigs&#39; you get all the three directions.</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">sbk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_seebeck</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
            <span class="n">sbk</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_seebeck</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="s1">&#39;eigs&#39;</span><span class="p">)</span>

        <span class="n">tlist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">sbk</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="k">if</span> <span class="n">temps</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span> <span class="k">else</span> <span class="n">temps</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="mi">14</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">]):</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span> <span class="o">+</span> <span class="n">i</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">temp</span> <span class="ow">in</span> <span class="n">tlist</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">],</span>
                                     <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">sbk</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">])[</span><span class="n">xyz</span><span class="p">],</span>
                                     <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                                     <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; K&#39;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">],</span> <span class="n">sbk</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">],</span>
                                 <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; K&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">dt</span> <span class="o">+</span> <span class="s1">&#39;-type&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Seebeck coefficient ($</span><span class="se">\\</span><span class="s2">mu$V/K)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Doping concentration (cm$^{-3}$)&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>

            <span class="n">p</span> <span class="o">=</span> <span class="s1">&#39;lower right&#39;</span> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="n">p</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_conductivity_dop"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_conductivity_dop">[docs]</a>    <span class="k">def</span> <span class="nf">plot_conductivity_dop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temps</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">,</span>
                              <span class="n">relaxation_time</span><span class="o">=</span><span class="mf">1e-14</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the conductivity in function of doping levels for different</span>
<span class="sd">        temperatures.</span>

<span class="sd">        Args:</span>
<span class="sd">            temps: the default &#39;all&#39; plots all the temperatures in the analyzer.</span>
<span class="sd">                   Specify a list of temperatures if you want to plot only some.</span>
<span class="sd">            output: with &#39;average&#39; you get an average of the three directions</span>
<span class="sd">                    with &#39;eigs&#39; you get all the three directions.</span>
<span class="sd">            relaxation_time: specify a constant relaxation time value</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">cond</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_conductivity</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                             <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
            <span class="n">cond</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_conductivity</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                             <span class="n">output</span><span class="o">=</span><span class="s1">&#39;eigs&#39;</span><span class="p">)</span>

        <span class="n">tlist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">cond</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="k">if</span> <span class="n">temps</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span> <span class="k">else</span> <span class="n">temps</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="mi">14</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">]):</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span> <span class="o">+</span> <span class="n">i</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">temp</span> <span class="ow">in</span> <span class="n">tlist</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">],</span>
                                     <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">cond</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">])[</span><span class="n">xyz</span><span class="p">],</span>
                                     <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                                     <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; K&#39;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">],</span> <span class="n">cond</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">],</span>
                                 <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; K&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">dt</span> <span class="o">+</span> <span class="s1">&#39;-type&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;conductivity $</span><span class="se">\\</span><span class="s2">sigma$ (1/($</span><span class="se">\\</span><span class="s2">Omega$ m))&quot;</span><span class="p">,</span>
                           <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Doping concentration ($cm^{-3}$)&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ticklabel_format</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s1">&#39;sci&#39;</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">scilimits</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_power_factor_dop"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_power_factor_dop">[docs]</a>    <span class="k">def</span> <span class="nf">plot_power_factor_dop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temps</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">,</span>
                              <span class="n">relaxation_time</span><span class="o">=</span><span class="mf">1e-14</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the Power Factor in function of doping levels for different temperatures.</span>

<span class="sd">        Args:</span>
<span class="sd">            temps: the default &#39;all&#39; plots all the temperatures in the analyzer.</span>
<span class="sd">                   Specify a list of temperatures if you want to plot only some.</span>
<span class="sd">            output: with &#39;average&#39; you get an average of the three directions</span>
<span class="sd">                    with &#39;eigs&#39; you get all the three directions.</span>
<span class="sd">            relaxation_time: specify a constant relaxation time value</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">pf</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_power_factor</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                           <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
            <span class="n">pf</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_power_factor</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                           <span class="n">output</span><span class="o">=</span><span class="s1">&#39;eigs&#39;</span><span class="p">)</span>

        <span class="n">tlist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">pf</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="k">if</span> <span class="n">temps</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span> <span class="k">else</span> <span class="n">temps</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="mi">14</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">]):</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span> <span class="o">+</span> <span class="n">i</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">temp</span> <span class="ow">in</span> <span class="n">tlist</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">],</span>
                                     <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">pf</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">])[</span><span class="n">xyz</span><span class="p">],</span>
                                     <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                                     <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; K&#39;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">],</span> <span class="n">pf</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">],</span>
                                 <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; K&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">dt</span> <span class="o">+</span> <span class="s1">&#39;-type&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Power Factor  ($</span><span class="se">\\</span><span class="s2">mu$W/(mK$^2$))&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Doping concentration ($cm^{-3}$)&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ticklabel_format</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s1">&#39;sci&#39;</span><span class="p">,</span> <span class="n">axis</span><span class="o">=</span><span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="n">scilimits</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
            <span class="n">p</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>  <span class="c1"># &#39;lower right&#39; if i == 0 else &#39;&#39;</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="n">p</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_zt_dop"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_zt_dop">[docs]</a>    <span class="k">def</span> <span class="nf">plot_zt_dop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temps</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">,</span> <span class="n">relaxation_time</span><span class="o">=</span><span class="mf">1e-14</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the figure of merit zT in function of doping levels for different</span>
<span class="sd">        temperatures.</span>

<span class="sd">        Args:</span>
<span class="sd">            temps: the default &#39;all&#39; plots all the temperatures in the analyzer.</span>
<span class="sd">                   Specify a list of temperatures if you want to plot only some.</span>
<span class="sd">            output: with &#39;average&#39; you get an average of the three directions</span>
<span class="sd">                    with &#39;eigs&#39; you get all the three directions.</span>
<span class="sd">            relaxation_time: specify a constant relaxation time value</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">zt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_zt</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span>
                                 <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
            <span class="n">zt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_zt</span><span class="p">(</span><span class="n">relaxation_time</span><span class="o">=</span><span class="n">relaxation_time</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;eigs&#39;</span><span class="p">)</span>

        <span class="n">tlist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">zt</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="k">if</span> <span class="n">temps</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span> <span class="k">else</span> <span class="n">temps</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="mi">14</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">]):</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span> <span class="o">+</span> <span class="n">i</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">temp</span> <span class="ow">in</span> <span class="n">tlist</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">],</span>
                                     <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">zt</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">])[</span><span class="n">xyz</span><span class="p">],</span>
                                     <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                                     <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; K&#39;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">],</span> <span class="n">zt</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">],</span>
                                 <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; K&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">dt</span> <span class="o">+</span> <span class="s1">&#39;-type&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;zT&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Doping concentration ($cm^{-3}$)&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>

            <span class="n">p</span> <span class="o">=</span> <span class="s1">&#39;lower right&#39;</span> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="n">p</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_eff_mass_dop"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_eff_mass_dop">[docs]</a>    <span class="k">def</span> <span class="nf">plot_eff_mass_dop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temps</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the average effective mass in function of doping levels</span>
<span class="sd">        for different temperatures.</span>

<span class="sd">        Args:</span>
<span class="sd">            temps: the default &#39;all&#39; plots all the temperatures in the analyzer.</span>
<span class="sd">                   Specify a list of temperatures if you want to plot only some.</span>
<span class="sd">            output: with &#39;average&#39; you get an average of the three directions</span>
<span class="sd">                    with &#39;eigs&#39; you get all the three directions.</span>
<span class="sd">            relaxation_time: specify a constant relaxation time value</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
            <span class="n">em</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_average_eff_mass</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="s1">&#39;average&#39;</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
            <span class="n">em</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_average_eff_mass</span><span class="p">(</span><span class="n">output</span><span class="o">=</span><span class="s1">&#39;eigs&#39;</span><span class="p">)</span>

        <span class="n">tlist</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">em</span><span class="p">[</span><span class="s1">&#39;n&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span> <span class="k">if</span> <span class="n">temps</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span> <span class="k">else</span> <span class="n">temps</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="mi">14</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">dt</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">([</span><span class="s1">&#39;n&#39;</span><span class="p">,</span> <span class="s1">&#39;p&#39;</span><span class="p">]):</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">121</span> <span class="o">+</span> <span class="n">i</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">temp</span> <span class="ow">in</span> <span class="n">tlist</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;eigs&#39;</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">xyz</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">],</span>
                                     <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">em</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">])[</span><span class="n">xyz</span><span class="p">],</span>
                                     <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span>
                                     <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">xyz</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; K&#39;</span><span class="p">)</span>
                <span class="k">elif</span> <span class="n">output</span> <span class="o">==</span> <span class="s1">&#39;average&#39;</span><span class="p">:</span>
                    <span class="n">plt</span><span class="o">.</span><span class="n">semilogx</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">doping</span><span class="p">[</span><span class="n">dt</span><span class="p">],</span> <span class="n">em</span><span class="p">[</span><span class="n">dt</span><span class="p">][</span><span class="n">temp</span><span class="p">],</span>
                                 <span class="n">marker</span><span class="o">=</span><span class="s1">&#39;s&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39; K&#39;</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">title</span><span class="p">(</span><span class="n">dt</span> <span class="o">+</span> <span class="s1">&#39;-type&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">20</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Effective mass (m$_e$)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s1">&#39;Doping concentration ($cm^{-3}$)&#39;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>

            <span class="n">p</span> <span class="o">=</span> <span class="s1">&#39;lower right&#39;</span> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span> <span class="k">else</span> <span class="s1">&#39;&#39;</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="n">p</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">15</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">grid</span><span class="p">()</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>

        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_dos"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_dos">[docs]</a>    <span class="k">def</span> <span class="nf">plot_dos</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sigma</span><span class="o">=</span><span class="mf">0.05</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        plot dos</span>

<span class="sd">        Args:</span>
<span class="sd">            sigma: a smearing</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">plotter</span> <span class="o">=</span> <span class="n">DosPlotter</span><span class="p">(</span><span class="n">sigma</span><span class="o">=</span><span class="n">sigma</span><span class="p">)</span>
        <span class="n">plotter</span><span class="o">.</span><span class="n">add_dos</span><span class="p">(</span><span class="s2">&quot;t&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">dos</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">plotter</span><span class="o">.</span><span class="n">get_plot</span><span class="p">()</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_carriers"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_carriers">[docs]</a>    <span class="k">def</span> <span class="nf">plot_carriers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temp</span><span class="o">=</span><span class="mi">300</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the carrier concentration in function of Fermi level</span>

<span class="sd">        Args:</span>
<span class="sd">            temp: the temperature</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">semilogy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_steps</span><span class="p">,</span>
                     <span class="nb">abs</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">_carrier_conc</span><span class="p">[</span><span class="n">temp</span><span class="p">]</span> <span class="o">/</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">vol</span> <span class="o">*</span> <span class="mf">1e-24</span><span class="p">)),</span>
                     <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;r&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_bg_limits</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_doping</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">gap</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="mf">1e14</span><span class="p">,</span> <span class="mf">1e22</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;carrier concentration (cm-3)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s2">&quot;E-E$_f$ (eV)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="BoltztrapPlotter.plot_hall_carriers"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.BoltztrapPlotter.plot_hall_carriers">[docs]</a>    <span class="k">def</span> <span class="nf">plot_hall_carriers</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">temp</span><span class="o">=</span><span class="mi">300</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Plot the Hall carrier concentration in function of Fermi level</span>

<span class="sd">        Args:</span>
<span class="sd">            temp: the temperature</span>

<span class="sd">        Returns:</span>
<span class="sd">            a matplotlib object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
        <span class="n">hall_carriers</span> <span class="o">=</span> <span class="p">[</span><span class="nb">abs</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span>
                         <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">get_hall_carrier_concentration</span><span class="p">()[</span><span class="n">temp</span><span class="p">]]</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">semilogy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">mu_steps</span><span class="p">,</span>
                     <span class="n">hall_carriers</span><span class="p">,</span>
                     <span class="n">linewidth</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s1">&#39;r&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_bg_limits</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_plot_doping</span><span class="p">(</span><span class="n">temp</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="o">-</span><span class="mf">0.5</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_bz</span><span class="o">.</span><span class="n">gap</span> <span class="o">+</span> <span class="mf">0.5</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="mf">1e14</span><span class="p">,</span> <span class="mf">1e22</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="s2">&quot;Hall carrier concentration (cm-3)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mf">30.0</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="s2">&quot;E-E$_f$ (eV)&quot;</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">xticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">yticks</span><span class="p">(</span><span class="n">fontsize</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">plt</span></div></div>


<div class="viewcode-block" id="CohpPlotter"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.CohpPlotter">[docs]</a><span class="k">class</span> <span class="nc">CohpPlotter</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class for plotting crystal orbital Hamilton populations (COHPs) or</span>
<span class="sd">    crystal orbital overlap populations (COOPs). It is modeled after the</span>
<span class="sd">    DosPlotter object.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zero_at_efermi</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">are_coops</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            zero_at_efermi: Whether to shift all populations to have zero</span>
<span class="sd">                energy at the Fermi level. Defaults to True.</span>
<span class="sd">            are_coops: Switch to indicate that these are COOPs, not COHPs.</span>
<span class="sd">                Defaults to False for COHPs.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">zero_at_efermi</span> <span class="o">=</span> <span class="n">zero_at_efermi</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">are_coops</span> <span class="o">=</span> <span class="n">are_coops</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span> <span class="o">=</span> <span class="n">OrderedDict</span><span class="p">()</span>

<div class="viewcode-block" id="CohpPlotter.add_cohp"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.CohpPlotter.add_cohp">[docs]</a>    <span class="k">def</span> <span class="nf">add_cohp</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">label</span><span class="p">,</span> <span class="n">cohp</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Adds a COHP for plotting.</span>

<span class="sd">        Args:</span>
<span class="sd">            label: Label for the COHP. Must be unique.</span>

<span class="sd">            cohp: COHP object.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">energies</span> <span class="o">=</span> <span class="n">cohp</span><span class="o">.</span><span class="n">energies</span> <span class="o">-</span> <span class="n">cohp</span><span class="o">.</span><span class="n">efermi</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">zero_at_efermi</span> \
            <span class="k">else</span> <span class="n">cohp</span><span class="o">.</span><span class="n">energies</span>
        <span class="n">populations</span> <span class="o">=</span> <span class="n">cohp</span><span class="o">.</span><span class="n">get_cohp</span><span class="p">()</span>
        <span class="n">int_populations</span> <span class="o">=</span> <span class="n">cohp</span><span class="o">.</span><span class="n">get_icohp</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="p">[</span><span class="n">label</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;energies&quot;</span><span class="p">:</span> <span class="n">energies</span><span class="p">,</span> <span class="s2">&quot;COHP&quot;</span><span class="p">:</span> <span class="n">populations</span><span class="p">,</span>
                              <span class="s2">&quot;ICOHP&quot;</span><span class="p">:</span> <span class="n">int_populations</span><span class="p">,</span> <span class="s2">&quot;efermi&quot;</span><span class="p">:</span> <span class="n">cohp</span><span class="o">.</span><span class="n">efermi</span><span class="p">}</span></div>

<div class="viewcode-block" id="CohpPlotter.add_cohp_dict"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.CohpPlotter.add_cohp_dict">[docs]</a>    <span class="k">def</span> <span class="nf">add_cohp_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cohp_dict</span><span class="p">,</span> <span class="n">key_sort_func</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Adds a dictionary of COHPs with an optional sorting function</span>
<span class="sd">        for the keys.</span>

<span class="sd">        Args:</span>
<span class="sd">            cohp_dict: dict of the form {label: Cohp}</span>

<span class="sd">            key_sort_func: function used to sort the cohp_dict keys.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">key_sort_func</span><span class="p">:</span>
            <span class="n">keys</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">cohp_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span> <span class="n">key</span><span class="o">=</span><span class="n">key_sort_func</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">keys</span> <span class="o">=</span> <span class="n">cohp_dict</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">label</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">add_cohp</span><span class="p">(</span><span class="n">label</span><span class="p">,</span> <span class="n">cohp_dict</span><span class="p">[</span><span class="n">label</span><span class="p">])</span></div>

<div class="viewcode-block" id="CohpPlotter.get_cohp_dict"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.CohpPlotter.get_cohp_dict">[docs]</a>    <span class="k">def</span> <span class="nf">get_cohp_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns the added COHPs as a json-serializable dict. Note that if you</span>
<span class="sd">        have specified smearing for the COHP plot, the populations returned</span>
<span class="sd">        will be the smeared and not the original populations.</span>

<span class="sd">        Returns:</span>
<span class="sd">            dict: Dict of COHP data of the form {label: {&quot;efermi&quot;: efermi,</span>
<span class="sd">            &quot;energies&quot;: ..., &quot;COHP&quot;: {Spin.up: ...}, &quot;ICOHP&quot;: ...}}.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">jsanitize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="p">)</span></div>

<div class="viewcode-block" id="CohpPlotter.get_plot"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.CohpPlotter.get_plot">[docs]</a>    <span class="k">def</span> <span class="nf">get_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">xlim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">plot_negative</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">integrated</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">invert_axes</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get a matplotlib plot showing the COHP.</span>

<span class="sd">        Args:</span>
<span class="sd">            xlim: Specifies the x-axis limits. Defaults to None for</span>
<span class="sd">                automatic determination.</span>

<span class="sd">            ylim: Specifies the y-axis limits. Defaults to None for</span>
<span class="sd">                automatic determination.</span>

<span class="sd">            plot_negative: It is common to plot -COHP(E) so that the</span>
<span class="sd">                sign means the same for COOPs and COHPs. Defaults to None</span>
<span class="sd">                for automatic determination: If are_coops is True, this</span>
<span class="sd">                will be set to False, else it will be set to True.</span>

<span class="sd">            integrated: Switch to plot ICOHPs. Defaults to False.</span>

<span class="sd">            invert_axes: Put the energies onto the y-axis, which is</span>
<span class="sd">                common in chemistry.</span>

<span class="sd">        Returns:</span>
<span class="sd">            A matplotlib object.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">are_coops</span><span class="p">:</span>
            <span class="n">cohp_label</span> <span class="o">=</span> <span class="s2">&quot;COOP&quot;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">cohp_label</span> <span class="o">=</span> <span class="s2">&quot;COHP&quot;</span>

        <span class="k">if</span> <span class="n">plot_negative</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">plot_negative</span> <span class="o">=</span> <span class="kc">True</span> <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">are_coops</span> <span class="k">else</span> <span class="kc">False</span>

        <span class="k">if</span> <span class="n">integrated</span><span class="p">:</span>
            <span class="n">cohp_label</span> <span class="o">=</span> <span class="s2">&quot;I&quot;</span> <span class="o">+</span> <span class="n">cohp_label</span> <span class="o">+</span> <span class="s2">&quot; (eV)&quot;</span>

        <span class="k">if</span> <span class="n">plot_negative</span><span class="p">:</span>
            <span class="n">cohp_label</span> <span class="o">=</span> <span class="s2">&quot;-&quot;</span> <span class="o">+</span> <span class="n">cohp_label</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">zero_at_efermi</span><span class="p">:</span>
            <span class="n">energy_label</span> <span class="o">=</span> <span class="s2">&quot;$E - E_f$ (eV)&quot;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">energy_label</span> <span class="o">=</span> <span class="s2">&quot;$E$ (eV)&quot;</span>

        <span class="n">ncolors</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="p">))</span>
        <span class="n">ncolors</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="mi">9</span><span class="p">,</span> <span class="n">ncolors</span><span class="p">)</span>

        <span class="kn">import</span> <span class="nn">palettable</span>

        <span class="n">colors</span> <span class="o">=</span> <span class="n">palettable</span><span class="o">.</span><span class="n">colorbrewer</span><span class="o">.</span><span class="n">qualitative</span><span class="o">.</span><span class="n">Set1_9</span><span class="o">.</span><span class="n">mpl_colors</span>

        <span class="n">plt</span> <span class="o">=</span> <span class="n">pretty_plot</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">8</span><span class="p">)</span>

        <span class="n">allpts</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">keys</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">key</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">keys</span><span class="p">):</span>
            <span class="n">energies</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s2">&quot;energies&quot;</span><span class="p">]</span>
            <span class="k">if</span> <span class="ow">not</span> <span class="n">integrated</span><span class="p">:</span>
                <span class="n">populations</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s2">&quot;COHP&quot;</span><span class="p">]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">populations</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s2">&quot;ICOHP&quot;</span><span class="p">]</span>
            <span class="k">for</span> <span class="n">spin</span> <span class="ow">in</span> <span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">,</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]:</span>
                <span class="k">if</span> <span class="n">spin</span> <span class="ow">in</span> <span class="n">populations</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">invert_axes</span><span class="p">:</span>
                        <span class="n">x</span> <span class="o">=</span> <span class="o">-</span><span class="n">populations</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="k">if</span> <span class="n">plot_negative</span> \
                            <span class="k">else</span> <span class="n">populations</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span>
                        <span class="n">y</span> <span class="o">=</span> <span class="n">energies</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">x</span> <span class="o">=</span> <span class="n">energies</span>
                        <span class="n">y</span> <span class="o">=</span> <span class="o">-</span><span class="n">populations</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="k">if</span> <span class="n">plot_negative</span> \
                            <span class="k">else</span> <span class="n">populations</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span>
                    <span class="n">allpts</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)))</span>
                    <span class="k">if</span> <span class="n">spin</span> <span class="o">==</span> <span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">:</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">i</span> <span class="o">%</span> <span class="n">ncolors</span><span class="p">],</span>
                                 <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;-&#39;</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">key</span><span class="p">),</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">i</span> <span class="o">%</span> <span class="n">ncolors</span><span class="p">],</span>
                                 <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">xlim</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">(</span><span class="n">xlim</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">ylim</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">(</span><span class="n">ylim</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">xlim</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">()</span>
            <span class="n">relevanty</span> <span class="o">=</span> <span class="p">[</span><span class="n">p</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">allpts</span> <span class="k">if</span> <span class="n">xlim</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&lt;</span> <span class="n">p</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&lt;</span> <span class="n">xlim</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">((</span><span class="nb">min</span><span class="p">(</span><span class="n">relevanty</span><span class="p">),</span> <span class="nb">max</span><span class="p">(</span><span class="n">relevanty</span><span class="p">)))</span>

        <span class="n">xlim</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">xlim</span><span class="p">()</span>
        <span class="n">ylim</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">ylim</span><span class="p">()</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">invert_axes</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xlim</span><span class="p">,</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="s2">&quot;k-&quot;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">zero_at_efermi</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">ylim</span><span class="p">,</span> <span class="s2">&quot;k--&quot;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s1">&#39;efermi&#39;</span><span class="p">],</span>
                          <span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s1">&#39;efermi&#39;</span><span class="p">]],</span> <span class="n">ylim</span><span class="p">,</span>
                         <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">i</span> <span class="o">%</span> <span class="n">ncolors</span><span class="p">],</span>
                         <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">ylim</span><span class="p">,</span> <span class="s2">&quot;k-&quot;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">zero_at_efermi</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xlim</span><span class="p">,</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="s2">&quot;k--&quot;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">plt</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xlim</span><span class="p">,</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s1">&#39;efermi&#39;</span><span class="p">],</span>
                                <span class="bp">self</span><span class="o">.</span><span class="n">_cohps</span><span class="p">[</span><span class="n">key</span><span class="p">][</span><span class="s1">&#39;efermi&#39;</span><span class="p">]],</span>
                         <span class="n">color</span><span class="o">=</span><span class="n">colors</span><span class="p">[</span><span class="n">i</span> <span class="o">%</span> <span class="n">ncolors</span><span class="p">],</span>
                         <span class="n">linestyle</span><span class="o">=</span><span class="s1">&#39;--&#39;</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">invert_axes</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="n">cohp_label</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="n">energy_label</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">xlabel</span><span class="p">(</span><span class="n">energy_label</span><span class="p">)</span>
            <span class="n">plt</span><span class="o">.</span><span class="n">ylabel</span><span class="p">(</span><span class="n">cohp_label</span><span class="p">)</span>

        <span class="n">plt</span><span class="o">.</span><span class="n">legend</span><span class="p">()</span>
        <span class="n">leg</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">gca</span><span class="p">()</span><span class="o">.</span><span class="n">get_legend</span><span class="p">()</span>
        <span class="n">ltext</span> <span class="o">=</span> <span class="n">leg</span><span class="o">.</span><span class="n">get_texts</span><span class="p">()</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">setp</span><span class="p">(</span><span class="n">ltext</span><span class="p">,</span> <span class="n">fontsize</span><span class="o">=</span><span class="mi">30</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">tight_layout</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">plt</span></div>

<div class="viewcode-block" id="CohpPlotter.save_plot"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.CohpPlotter.save_plot">[docs]</a>    <span class="k">def</span> <span class="nf">save_plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">,</span> <span class="n">img_format</span><span class="o">=</span><span class="s2">&quot;eps&quot;</span><span class="p">,</span> <span class="n">xlim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Save matplotlib plot to a file.</span>

<span class="sd">        Args:</span>
<span class="sd">            filename: File name to write to.</span>
<span class="sd">            img_format: Image format to use. Defaults to EPS.</span>
<span class="sd">            xlim: Specifies the x-axis limits. Defaults to None for</span>
<span class="sd">                automatic determination.</span>
<span class="sd">            ylim: Specifies the y-axis limits. Defaults to None for</span>
<span class="sd">                automatic determination.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_plot</span><span class="p">(</span><span class="n">xlim</span><span class="p">,</span> <span class="n">ylim</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">savefig</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="n">img_format</span><span class="p">)</span></div>

<div class="viewcode-block" id="CohpPlotter.show"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.CohpPlotter.show">[docs]</a>    <span class="k">def</span> <span class="nf">show</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">xlim</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">ylim</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Show the plot using matplotlib.</span>

<span class="sd">        Args:</span>
<span class="sd">            xlim: Specifies the x-axis limits. Defaults to None for</span>
<span class="sd">                automatic determination.</span>
<span class="sd">            ylim: Specifies the y-axis limits. Defaults to None for</span>
<span class="sd">                automatic determination.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">plt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_plot</span><span class="p">(</span><span class="n">xlim</span><span class="p">,</span> <span class="n">ylim</span><span class="p">)</span>
        <span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span></div></div>


<div class="viewcode-block" id="plot_fermi_surface"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.plot_fermi_surface">[docs]</a><span class="nd">@requires</span><span class="p">(</span><span class="n">mlab</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">,</span> <span class="s2">&quot;MayAvi mlab not imported! Please install mayavi.&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">plot_fermi_surface</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">structure</span><span class="p">,</span> <span class="n">cbm</span><span class="p">,</span> <span class="n">energy_levels</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                       <span class="n">multiple_figure</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">mlab_figure</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                       <span class="n">kpoints_dict</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">colors</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">transparency_factor</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                       <span class="n">labels_scale_factor</span><span class="o">=</span><span class="mf">0.05</span><span class="p">,</span> <span class="n">points_scale_factor</span><span class="o">=</span><span class="mf">0.02</span><span class="p">,</span>
                       <span class="n">interative</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Plot the Fermi surface at specific energy value using Boltztrap 1 FERMI</span>
<span class="sd">    mode.</span>

<span class="sd">    The easiest way to use this plotter is:</span>

<span class="sd">        1. Run boltztrap in &#39;FERMI&#39; mode using BoltztrapRunner,</span>
<span class="sd">        2. Load BoltztrapAnalyzer using your method of choice (e.g., from_files)</span>
<span class="sd">        3. Pass in your BoltztrapAnalyzer&#39;s fermi_surface_data as this</span>
<span class="sd">            function&#39;s data argument.</span>

<span class="sd">    Args:</span>
<span class="sd">        data: energy values in a 3D grid from a CUBE file via read_cube_file</span>
<span class="sd">            function, or from a BoltztrapAnalyzer.fermi_surface_data</span>
<span class="sd">        structure: structure object of the material</span>
<span class="sd">        energy_levels ([float]): Energy values for plotting the fermi surface(s)</span>
<span class="sd">            By default 0 eV correspond to the VBM, as in the plot of band</span>
<span class="sd">            structure along symmetry line.</span>
<span class="sd">            Default: One surface, with max energy value + 0.01 eV</span>
<span class="sd">        cbm (bool): Boolean value to specify if the considered band is a</span>
<span class="sd">            conduction band or not</span>
<span class="sd">        multiple_figure (bool): If True a figure for each energy level will be</span>
<span class="sd">            shown.  If False all the surfaces will be shown in the same figure.</span>
<span class="sd">            In this last case, tune the transparency factor.</span>
<span class="sd">        mlab_figure (mayavi.mlab.figure): A previous figure to plot a new</span>
<span class="sd">            surface on.</span>
<span class="sd">        kpoints_dict (dict): dictionary of kpoints to label in the plot.</span>
<span class="sd">            Example: {&quot;K&quot;:[0.5,0.0,0.5]}, coords are fractional</span>
<span class="sd">        colors ([tuple]): Iterable of 3-tuples (r,g,b) of integers to define</span>
<span class="sd">            the colors of each surface (one per energy level).</span>
<span class="sd">            Should be the same length as the number of surfaces being plotted.</span>
<span class="sd">            Example (3 surfaces): colors=[(1,0,0), (0,1,0), (0,0,1)]</span>
<span class="sd">            Example (2 surfaces): colors=[(0, 0.5, 0.5)]</span>
<span class="sd">        transparency_factor [float]: Values in the range [0,1] to tune the</span>
<span class="sd">            opacity of each surface. Should be one transparency_factor per</span>
<span class="sd">            surface.</span>
<span class="sd">        labels_scale_factor (float): factor to tune size of the kpoint labels</span>
<span class="sd">        points_scale_factor (float): factor to tune size of the kpoint points</span>
<span class="sd">        interative (bool): if True an interactive figure will be shown.</span>
<span class="sd">            If False a non interactive figure will be shown, but it is possible</span>
<span class="sd">            to plot other surfaces on the same figure. To make it interactive,</span>
<span class="sd">            run mlab.show().</span>
<span class="sd">    Returns:</span>
<span class="sd">        ((mayavi.mlab.figure, mayavi.mlab)): The mlab plotter and an interactive</span>
<span class="sd">            figure to control the plot.</span>

<span class="sd">    Note: Experimental.</span>
<span class="sd">          Please, double check the surface shown by using some</span>
<span class="sd">          other software and report issues.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">bz</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">reciprocal_lattice</span><span class="o">.</span><span class="n">get_wigner_seitz_cell</span><span class="p">()</span>
    <span class="n">cell</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">reciprocal_lattice</span><span class="o">.</span><span class="n">matrix</span>

    <span class="n">fact</span> <span class="o">=</span> <span class="mi">1</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">cbm</span> <span class="k">else</span> <span class="o">-</span><span class="mi">1</span>
    <span class="n">data_1d</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">ravel</span><span class="p">()</span>
    <span class="n">en_min</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="n">fact</span> <span class="o">*</span> <span class="n">data_1d</span><span class="p">)</span>
    <span class="n">en_max</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">fact</span> <span class="o">*</span> <span class="n">data_1d</span><span class="p">)</span>

    <span class="k">if</span> <span class="n">energy_levels</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
        <span class="n">energy_levels</span> <span class="o">=</span> <span class="p">[</span><span class="n">en_min</span> <span class="o">+</span> <span class="mf">0.01</span><span class="p">]</span> <span class="k">if</span> <span class="n">cbm</span> <span class="k">else</span> <span class="p">[</span><span class="n">en_max</span> <span class="o">-</span> <span class="mf">0.01</span><span class="p">]</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Energy level set to: &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">energy_levels</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">+</span> <span class="s2">&quot; eV&quot;</span><span class="p">)</span>

    <span class="k">else</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">energy_levels</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">e</span> <span class="o">&gt;</span> <span class="n">en_max</span> <span class="ow">or</span> <span class="n">e</span> <span class="o">&lt;</span> <span class="n">en_min</span><span class="p">:</span>
                <span class="k">raise</span> <span class="n">BoltztrapError</span><span class="p">(</span>
                    <span class="s2">&quot;energy level &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="o">+</span>
                    <span class="s2">&quot; not in the range of possible energies: [&quot;</span> <span class="o">+</span>
                    <span class="nb">str</span><span class="p">(</span><span class="n">en_min</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;, &quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">en_max</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;]&quot;</span>
                <span class="p">)</span>

    <span class="n">n_surfaces</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">energy_levels</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">colors</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
        <span class="n">colors</span> <span class="o">=</span> <span class="p">[(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)]</span> <span class="o">*</span> <span class="n">n_surfaces</span>

    <span class="k">if</span> <span class="n">transparency_factor</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
        <span class="n">transparency_factor</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">n_surfaces</span>

    <span class="k">if</span> <span class="n">mlab_figure</span><span class="p">:</span>
        <span class="n">fig</span> <span class="o">=</span> <span class="n">mlab_figure</span>

    <span class="k">if</span> <span class="n">kpoints_dict</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
        <span class="n">kpoints_dict</span> <span class="o">=</span> <span class="p">{}</span>

    <span class="k">if</span> <span class="n">mlab_figure</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">multiple_figure</span><span class="p">:</span>
        <span class="n">fig</span> <span class="o">=</span> <span class="n">mlab</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">1024</span><span class="p">,</span> <span class="mi">768</span><span class="p">),</span> <span class="n">bgcolor</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">iface</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bz</span><span class="p">)):</span>
            <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">itertools</span><span class="o">.</span><span class="n">combinations</span><span class="p">(</span><span class="n">bz</span><span class="p">[</span><span class="n">iface</span><span class="p">],</span> <span class="mi">2</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">jface</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bz</span><span class="p">)):</span>
                    <span class="k">if</span> <span class="n">iface</span> <span class="o">&lt;</span> <span class="n">jface</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="n">x</span><span class="p">)</span>
                                             <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">bz</span><span class="p">[</span><span class="n">jface</span><span class="p">])</span> <span class="ow">and</span> \
                            <span class="nb">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="n">x</span><span class="p">)</span>
                                <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">bz</span><span class="p">[</span><span class="n">jface</span><span class="p">]):</span>
                        <span class="n">mlab</span><span class="o">.</span><span class="n">plot3d</span><span class="p">(</span><span class="o">*</span><span class="nb">zip</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span> <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
                                    <span class="n">tube_radius</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">figure</span><span class="o">=</span><span class="n">fig</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">label</span><span class="p">,</span> <span class="n">coords</span> <span class="ow">in</span> <span class="n">kpoints_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="n">label_coords</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">reciprocal_lattice</span> \
                <span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">(</span><span class="n">coords</span><span class="p">)</span>
            <span class="n">mlab</span><span class="o">.</span><span class="n">points3d</span><span class="p">(</span><span class="o">*</span><span class="n">label_coords</span><span class="p">,</span> <span class="n">scale_factor</span><span class="o">=</span><span class="n">points_scale_factor</span><span class="p">,</span>
                          <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">figure</span><span class="o">=</span><span class="n">fig</span><span class="p">)</span>
            <span class="n">mlab</span><span class="o">.</span><span class="n">text3d</span><span class="p">(</span><span class="o">*</span><span class="n">label_coords</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="n">label</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="n">labels_scale_factor</span><span class="p">,</span>
                        <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">figure</span><span class="o">=</span><span class="n">fig</span><span class="p">)</span>

    <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">isolevel</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">energy_levels</span><span class="p">):</span>
        <span class="n">alpha</span> <span class="o">=</span> <span class="n">transparency_factor</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
        <span class="n">color</span> <span class="o">=</span> <span class="n">colors</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
        <span class="k">if</span> <span class="n">multiple_figure</span><span class="p">:</span>
            <span class="n">fig</span> <span class="o">=</span> <span class="n">mlab</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">1024</span><span class="p">,</span> <span class="mi">768</span><span class="p">),</span> <span class="n">bgcolor</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>

            <span class="k">for</span> <span class="n">iface</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bz</span><span class="p">)):</span>
                <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">itertools</span><span class="o">.</span><span class="n">combinations</span><span class="p">(</span><span class="n">bz</span><span class="p">[</span><span class="n">iface</span><span class="p">],</span> <span class="mi">2</span><span class="p">):</span>
                    <span class="k">for</span> <span class="n">jface</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bz</span><span class="p">)):</span>
                        <span class="k">if</span> <span class="n">iface</span> <span class="o">&lt;</span> <span class="n">jface</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="n">x</span><span class="p">)</span>
                                                 <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">bz</span><span class="p">[</span><span class="n">jface</span><span class="p">])</span> <span class="ow">and</span> \
                                <span class="nb">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="n">x</span><span class="p">)</span>
                                    <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">bz</span><span class="p">[</span><span class="n">jface</span><span class="p">]):</span>
                            <span class="n">mlab</span><span class="o">.</span><span class="n">plot3d</span><span class="p">(</span><span class="o">*</span><span class="nb">zip</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span> <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
                                        <span class="n">tube_radius</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">figure</span><span class="o">=</span><span class="n">fig</span><span class="p">)</span>

            <span class="k">for</span> <span class="n">label</span><span class="p">,</span> <span class="n">coords</span> <span class="ow">in</span> <span class="n">kpoints_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="n">label_coords</span> <span class="o">=</span> <span class="n">structure</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">reciprocal_lattice</span> \
                    <span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">(</span><span class="n">coords</span><span class="p">)</span>
                <span class="n">mlab</span><span class="o">.</span><span class="n">points3d</span><span class="p">(</span><span class="o">*</span><span class="n">label_coords</span><span class="p">,</span> <span class="n">scale_factor</span><span class="o">=</span><span class="n">points_scale_factor</span><span class="p">,</span>
                              <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">figure</span><span class="o">=</span><span class="n">fig</span><span class="p">)</span>
                <span class="n">mlab</span><span class="o">.</span><span class="n">text3d</span><span class="p">(</span><span class="o">*</span><span class="n">label_coords</span><span class="p">,</span> <span class="n">text</span><span class="o">=</span><span class="n">label</span><span class="p">,</span>
                            <span class="n">scale</span><span class="o">=</span><span class="n">labels_scale_factor</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span>
                            <span class="n">figure</span><span class="o">=</span><span class="n">fig</span><span class="p">)</span>

        <span class="n">cp</span> <span class="o">=</span> <span class="n">mlab</span><span class="o">.</span><span class="n">contour3d</span><span class="p">(</span><span class="n">fact</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span> <span class="n">contours</span><span class="o">=</span><span class="p">[</span><span class="n">isolevel</span><span class="p">],</span> <span class="n">transparent</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                            <span class="n">colormap</span><span class="o">=</span><span class="s1">&#39;hot&#39;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="n">color</span><span class="p">,</span> <span class="n">opacity</span><span class="o">=</span><span class="n">alpha</span><span class="p">,</span>
                            <span class="n">figure</span><span class="o">=</span><span class="n">fig</span><span class="p">)</span>

        <span class="n">polydata</span> <span class="o">=</span> <span class="n">cp</span><span class="o">.</span><span class="n">actor</span><span class="o">.</span><span class="n">actors</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">mapper</span><span class="o">.</span><span class="n">input</span>
        <span class="n">pts</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">polydata</span><span class="o">.</span><span class="n">points</span><span class="p">)</span>  <span class="c1"># - 1</span>
        <span class="n">polydata</span><span class="o">.</span><span class="n">points</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">pts</span><span class="p">,</span>
                                 <span class="n">cell</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">shape</span><span class="p">)[:,</span> <span class="n">np</span><span class="o">.</span><span class="n">newaxis</span><span class="p">])</span>

        <span class="n">cx</span><span class="p">,</span> <span class="n">cy</span><span class="p">,</span> <span class="n">cz</span> <span class="o">=</span> <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">polydata</span><span class="o">.</span><span class="n">points</span><span class="p">)[:,</span> <span class="n">i</span><span class="p">])</span>
                      <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">)]</span>

        <span class="n">polydata</span><span class="o">.</span><span class="n">points</span> <span class="o">=</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">polydata</span><span class="o">.</span><span class="n">points</span><span class="p">)</span> <span class="o">-</span> <span class="p">[</span><span class="n">cx</span><span class="p">,</span> <span class="n">cy</span><span class="p">,</span> <span class="n">cz</span><span class="p">])</span> <span class="o">*</span> <span class="mi">2</span>

        <span class="c1"># mlab.view(distance=&#39;auto&#39;)</span>
        <span class="n">fig</span><span class="o">.</span><span class="n">scene</span><span class="o">.</span><span class="n">isometric_view</span><span class="p">()</span>

    <span class="k">if</span> <span class="n">interative</span><span class="p">:</span>
        <span class="n">mlab</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>

    <span class="k">return</span> <span class="n">fig</span><span class="p">,</span> <span class="n">mlab</span></div>


<div class="viewcode-block" id="plot_wigner_seitz"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.plot_wigner_seitz">[docs]</a><span class="k">def</span> <span class="nf">plot_wigner_seitz</span><span class="p">(</span><span class="n">lattice</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Adds the skeleton of the Wigner-Seitz cell of the lattice to a matplotlib Axes</span>

<span class="sd">    Args:</span>
<span class="sd">        lattice: Lattice object</span>
<span class="sd">        ax: matplotlib :class:`Axes` or None if a new figure should be created.</span>
<span class="sd">        kwargs: kwargs passed to the matplotlib function &#39;plot&#39;. Color defaults to black</span>
<span class="sd">            and linewidth to 1.</span>

<span class="sd">    Returns:</span>
<span class="sd">        matplotlib figure and matplotlib ax</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">ax</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">plt</span> <span class="o">=</span> <span class="n">get_ax3d_fig_plt</span><span class="p">(</span><span class="n">ax</span><span class="p">)</span>

    <span class="k">if</span> <span class="s2">&quot;color&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;color&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;k&quot;</span>
    <span class="k">if</span> <span class="s2">&quot;linewidth&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;linewidth&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>

    <span class="n">bz</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_wigner_seitz_cell</span><span class="p">()</span>
    <span class="n">ax</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">plt</span> <span class="o">=</span> <span class="n">get_ax3d_fig_plt</span><span class="p">(</span><span class="n">ax</span><span class="p">)</span>
    <span class="k">for</span> <span class="n">iface</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bz</span><span class="p">)):</span>
        <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">itertools</span><span class="o">.</span><span class="n">combinations</span><span class="p">(</span><span class="n">bz</span><span class="p">[</span><span class="n">iface</span><span class="p">],</span> <span class="mi">2</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">jface</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">bz</span><span class="p">)):</span>
                <span class="k">if</span> <span class="n">iface</span> <span class="o">&lt;</span> <span class="n">jface</span> <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span>
                        <span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">bz</span><span class="p">[</span><span class="n">jface</span><span class="p">])</span> \
                        <span class="ow">and</span> <span class="nb">any</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">all</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">bz</span><span class="p">[</span><span class="n">jface</span><span class="p">]):</span>
                    <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="o">*</span><span class="nb">zip</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span></div>


<div class="viewcode-block" id="plot_lattice_vectors"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.plot_lattice_vectors">[docs]</a><span class="k">def</span> <span class="nf">plot_lattice_vectors</span><span class="p">(</span><span class="n">lattice</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Adds the basis vectors of the lattice provided to a matplotlib Axes</span>

<span class="sd">    Args:</span>
<span class="sd">        lattice: Lattice object</span>
<span class="sd">        ax: matplotlib :class:`Axes` or None if a new figure should be created.</span>
<span class="sd">        kwargs: kwargs passed to the matplotlib function &#39;plot&#39;. Color defaults to green</span>
<span class="sd">            and linewidth to 3.</span>

<span class="sd">    Returns:</span>
<span class="sd">        matplotlib figure and matplotlib ax</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">ax</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">plt</span> <span class="o">=</span> <span class="n">get_ax3d_fig_plt</span><span class="p">(</span><span class="n">ax</span><span class="p">)</span>

    <span class="k">if</span> <span class="s2">&quot;color&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;color&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;g&quot;</span>
    <span class="k">if</span> <span class="s2">&quot;linewidth&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;linewidth&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">3</span>

    <span class="n">vertex1</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">([</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">])</span>
    <span class="n">vertex2</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">([</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">])</span>
    <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="o">*</span><span class="nb">zip</span><span class="p">(</span><span class="n">vertex1</span><span class="p">,</span> <span class="n">vertex2</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="n">vertex2</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">([</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">])</span>
    <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="o">*</span><span class="nb">zip</span><span class="p">(</span><span class="n">vertex1</span><span class="p">,</span> <span class="n">vertex2</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="n">vertex2</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">([</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">])</span>
    <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="o">*</span><span class="nb">zip</span><span class="p">(</span><span class="n">vertex1</span><span class="p">,</span> <span class="n">vertex2</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span></div>


<div class="viewcode-block" id="plot_path"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.plot_path">[docs]</a><span class="k">def</span> <span class="nf">plot_path</span><span class="p">(</span><span class="n">line</span><span class="p">,</span> <span class="n">lattice</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
              <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Adds a line passing through the coordinates listed in &#39;line&#39; to a matplotlib Axes</span>

<span class="sd">    Args:</span>
<span class="sd">        line: list of coordinates.</span>
<span class="sd">        lattice: Lattice object used to convert from reciprocal to cartesian coordinates</span>
<span class="sd">        coords_are_cartesian: Set to True if you are providing</span>
<span class="sd">            coordinates in cartesian coordinates. Defaults to False.</span>
<span class="sd">            Requires lattice if False.</span>
<span class="sd">        ax: matplotlib :class:`Axes` or None if a new figure should be created.</span>
<span class="sd">        kwargs: kwargs passed to the matplotlib function &#39;plot&#39;. Color defaults to red</span>
<span class="sd">            and linewidth to 3.</span>

<span class="sd">    Returns:</span>
<span class="sd">        matplotlib figure and matplotlib ax</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">ax</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">plt</span> <span class="o">=</span> <span class="n">get_ax3d_fig_plt</span><span class="p">(</span><span class="n">ax</span><span class="p">)</span>

    <span class="k">if</span> <span class="s2">&quot;color&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;color&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;r&quot;</span>
    <span class="k">if</span> <span class="s2">&quot;linewidth&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;linewidth&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">3</span>

    <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">line</span><span class="p">)):</span>
        <span class="n">vertex1</span> <span class="o">=</span> <span class="n">line</span><span class="p">[</span><span class="n">k</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
        <span class="n">vertex2</span> <span class="o">=</span> <span class="n">line</span><span class="p">[</span><span class="n">k</span><span class="p">]</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">coords_are_cartesian</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">lattice</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;coords_are_cartesian False requires the lattice&quot;</span><span class="p">)</span>
            <span class="n">vertex1</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">(</span><span class="n">vertex1</span><span class="p">)</span>
            <span class="n">vertex2</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">(</span><span class="n">vertex2</span><span class="p">)</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="o">*</span><span class="nb">zip</span><span class="p">(</span><span class="n">vertex1</span><span class="p">,</span> <span class="n">vertex2</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span></div>


<div class="viewcode-block" id="plot_labels"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.plot_labels">[docs]</a><span class="k">def</span> <span class="nf">plot_labels</span><span class="p">(</span><span class="n">labels</span><span class="p">,</span> <span class="n">lattice</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Adds labels to a matplotlib Axes</span>

<span class="sd">    Args:</span>
<span class="sd">        labels: dict containing the label as a key and the coordinates as value.</span>
<span class="sd">        lattice: Lattice object used to convert from reciprocal to cartesian coordinates</span>
<span class="sd">        coords_are_cartesian: Set to True if you are providing.</span>
<span class="sd">            coordinates in cartesian coordinates. Defaults to False.</span>
<span class="sd">            Requires lattice if False.</span>
<span class="sd">        ax: matplotlib :class:`Axes` or None if a new figure should be created.</span>
<span class="sd">        kwargs: kwargs passed to the matplotlib function &#39;text&#39;. Color defaults to blue</span>
<span class="sd">            and size to 25.</span>

<span class="sd">    Returns:</span>
<span class="sd">        matplotlib figure and matplotlib ax</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">ax</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">plt</span> <span class="o">=</span> <span class="n">get_ax3d_fig_plt</span><span class="p">(</span><span class="n">ax</span><span class="p">)</span>

    <span class="k">if</span> <span class="s2">&quot;color&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;color&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;b&quot;</span>
    <span class="k">if</span> <span class="s2">&quot;size&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;size&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">25</span>

    <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">coords</span> <span class="ow">in</span> <span class="n">labels</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
        <span class="n">label</span> <span class="o">=</span> <span class="n">k</span>
        <span class="k">if</span> <span class="n">k</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\\</span><span class="s2">&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">k</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;_&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
            <span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;$&quot;</span> <span class="o">+</span> <span class="n">k</span> <span class="o">+</span> <span class="s2">&quot;$&quot;</span>
        <span class="n">off</span> <span class="o">=</span> <span class="mf">0.01</span>
        <span class="k">if</span> <span class="n">coords_are_cartesian</span><span class="p">:</span>
            <span class="n">coords</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">coords</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">lattice</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;coords_are_cartesian False requires the lattice&quot;</span><span class="p">)</span>
            <span class="n">coords</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">(</span><span class="n">coords</span><span class="p">)</span>
        <span class="n">ax</span><span class="o">.</span><span class="n">text</span><span class="p">(</span><span class="o">*</span><span class="p">(</span><span class="n">coords</span> <span class="o">+</span> <span class="n">off</span><span class="p">),</span> <span class="n">s</span><span class="o">=</span><span class="n">label</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span></div>


<div class="viewcode-block" id="fold_point"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.fold_point">[docs]</a><span class="k">def</span> <span class="nf">fold_point</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">lattice</span><span class="p">,</span> <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Folds a point with coordinates p inside the first Brillouin zone of the lattice.</span>

<span class="sd">    Args:</span>
<span class="sd">        p: coordinates of one point</span>
<span class="sd">        lattice: Lattice object used to convert from reciprocal to cartesian coordinates</span>
<span class="sd">        coords_are_cartesian: Set to True if you are providing</span>
<span class="sd">            coordinates in cartesian coordinates. Defaults to False.</span>

<span class="sd">    Returns:</span>
<span class="sd">        The cartesian coordinates folded inside the first Brillouin zone</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="n">coords_are_cartesian</span><span class="p">:</span>
        <span class="n">p</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_fractional_coords</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">p</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>

    <span class="n">p</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mod</span><span class="p">(</span><span class="n">p</span> <span class="o">+</span> <span class="mf">0.5</span> <span class="o">-</span> <span class="mf">1e-10</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="o">-</span> <span class="mf">0.5</span> <span class="o">+</span> <span class="mf">1e-10</span>
    <span class="n">p</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>

    <span class="n">closest_lattice_point</span> <span class="o">=</span> <span class="kc">None</span>
    <span class="n">smallest_distance</span> <span class="o">=</span> <span class="mi">10000</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span>
                <span class="n">lattice_point</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">((</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span> <span class="n">k</span><span class="p">),</span> <span class="n">lattice</span><span class="o">.</span><span class="n">matrix</span><span class="p">)</span>
                <span class="n">dist</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">p</span> <span class="o">-</span> <span class="n">lattice_point</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">closest_lattice_point</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">dist</span> <span class="o">&lt;</span> <span class="n">smallest_distance</span><span class="p">:</span>
                    <span class="n">closest_lattice_point</span> <span class="o">=</span> <span class="n">lattice_point</span>
                    <span class="n">smallest_distance</span> <span class="o">=</span> <span class="n">dist</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">np</span><span class="o">.</span><span class="n">allclose</span><span class="p">(</span><span class="n">closest_lattice_point</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)):</span>
        <span class="n">p</span> <span class="o">=</span> <span class="n">p</span> <span class="o">-</span> <span class="n">closest_lattice_point</span>

    <span class="k">return</span> <span class="n">p</span></div>


<div class="viewcode-block" id="plot_points"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.plot_points">[docs]</a><span class="k">def</span> <span class="nf">plot_points</span><span class="p">(</span><span class="n">points</span><span class="p">,</span> <span class="n">lattice</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                <span class="n">ax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Adds Points to a matplotlib Axes</span>

<span class="sd">    Args:</span>
<span class="sd">        points: list of coordinates</span>
<span class="sd">        lattice: Lattice object used to convert from reciprocal to cartesian coordinates</span>
<span class="sd">        coords_are_cartesian: Set to True if you are providing</span>
<span class="sd">            coordinates in cartesian coordinates. Defaults to False.</span>
<span class="sd">            Requires lattice if False.</span>
<span class="sd">        fold: whether the points should be folded inside the first Brillouin Zone.</span>
<span class="sd">            Defaults to False. Requires lattice if True.</span>
<span class="sd">        ax: matplotlib :class:`Axes` or None if a new figure should be created.</span>
<span class="sd">        kwargs: kwargs passed to the matplotlib function &#39;scatter&#39;. Color defaults to blue</span>

<span class="sd">    Returns:</span>
<span class="sd">        matplotlib figure and matplotlib ax</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">ax</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">plt</span> <span class="o">=</span> <span class="n">get_ax3d_fig_plt</span><span class="p">(</span><span class="n">ax</span><span class="p">)</span>

    <span class="k">if</span> <span class="s2">&quot;color&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;color&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;b&quot;</span>

    <span class="k">if</span> <span class="p">(</span><span class="ow">not</span> <span class="n">coords_are_cartesian</span> <span class="ow">or</span> <span class="n">fold</span><span class="p">)</span> <span class="ow">and</span> <span class="n">lattice</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
            <span class="s2">&quot;coords_are_cartesian False or fold True require the lattice&quot;</span><span class="p">)</span>

    <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">points</span><span class="p">:</span>

        <span class="k">if</span> <span class="n">fold</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="n">fold_point</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">lattice</span><span class="p">,</span>
                           <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="n">coords_are_cartesian</span><span class="p">)</span>

        <span class="k">elif</span> <span class="ow">not</span> <span class="n">coords_are_cartesian</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>

        <span class="n">ax</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="o">*</span><span class="n">p</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span></div>


<div class="viewcode-block" id="plot_brillouin_zone_from_kpath"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.plot_brillouin_zone_from_kpath">[docs]</a><span class="nd">@add_fig_kwargs</span>
<span class="k">def</span> <span class="nf">plot_brillouin_zone_from_kpath</span><span class="p">(</span><span class="n">kpath</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Gives the plot (as a matplotlib object) of the symmetry line path in</span>
<span class="sd">        the Brillouin Zone.</span>

<span class="sd">    Args:</span>
<span class="sd">        kpath (HighSymmKpath): a HighSymmKPath object</span>
<span class="sd">        ax: matplotlib :class:`Axes` or None if a new figure should be created.</span>
<span class="sd">        **kwargs: provided by add_fig_kwargs decorator</span>

<span class="sd">    Returns:</span>
<span class="sd">        matplotlib figure</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">lines</span> <span class="o">=</span> <span class="p">[[</span><span class="n">kpath</span><span class="o">.</span><span class="n">kpath</span><span class="p">[</span><span class="s1">&#39;kpoints&#39;</span><span class="p">][</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">p</span><span class="p">]</span>
             <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">kpath</span><span class="o">.</span><span class="n">kpath</span><span class="p">[</span><span class="s1">&#39;path&#39;</span><span class="p">]]</span>
    <span class="k">return</span> <span class="n">plot_brillouin_zone</span><span class="p">(</span><span class="n">bz_lattice</span><span class="o">=</span><span class="n">kpath</span><span class="o">.</span><span class="n">prim_rec</span><span class="p">,</span> <span class="n">lines</span><span class="o">=</span><span class="n">lines</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">,</span>
                               <span class="n">labels</span><span class="o">=</span><span class="n">kpath</span><span class="o">.</span><span class="n">kpath</span><span class="p">[</span><span class="s1">&#39;kpoints&#39;</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>


<div class="viewcode-block" id="plot_brillouin_zone"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.plot_brillouin_zone">[docs]</a><span class="nd">@add_fig_kwargs</span>
<span class="k">def</span> <span class="nf">plot_brillouin_zone</span><span class="p">(</span><span class="n">bz_lattice</span><span class="p">,</span> <span class="n">lines</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">labels</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">kpoints</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                        <span class="n">fold</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                        <span class="n">ax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Plots a 3D representation of the Brillouin zone of the structure.</span>
<span class="sd">    Can add to the plot paths, labels and kpoints</span>

<span class="sd">    Args:</span>
<span class="sd">        bz_lattice: Lattice object of the Brillouin zone</span>
<span class="sd">        lines: list of lists of coordinates. Each list represent a different path</span>
<span class="sd">        labels: dict containing the label as a key and the coordinates as value.</span>
<span class="sd">        kpoints: list of coordinates</span>
<span class="sd">        fold: whether the points should be folded inside the first Brillouin Zone.</span>
<span class="sd">            Defaults to False. Requires lattice if True.</span>
<span class="sd">        coords_are_cartesian: Set to True if you are providing</span>
<span class="sd">            coordinates in cartesian coordinates. Defaults to False.</span>
<span class="sd">        ax: matplotlib :class:`Axes` or None if a new figure should be created.</span>
<span class="sd">        kwargs: provided by add_fig_kwargs decorator</span>

<span class="sd">    Returns:</span>
<span class="sd">        matplotlib figure</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">plot_lattice_vectors</span><span class="p">(</span><span class="n">bz_lattice</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">)</span>
    <span class="n">plot_wigner_seitz</span><span class="p">(</span><span class="n">bz_lattice</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">lines</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">:</span>
            <span class="n">plot_path</span><span class="p">(</span><span class="n">line</span><span class="p">,</span> <span class="n">bz_lattice</span><span class="p">,</span>
                      <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="n">coords_are_cartesian</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">)</span>

    <span class="k">if</span> <span class="n">labels</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
        <span class="n">plot_labels</span><span class="p">(</span><span class="n">labels</span><span class="p">,</span> <span class="n">bz_lattice</span><span class="p">,</span>
                    <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="n">coords_are_cartesian</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">)</span>
        <span class="n">plot_points</span><span class="p">(</span><span class="n">labels</span><span class="o">.</span><span class="n">values</span><span class="p">(),</span> <span class="n">bz_lattice</span><span class="p">,</span>
                    <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="n">coords_are_cartesian</span><span class="p">,</span>
                    <span class="n">fold</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">)</span>

    <span class="k">if</span> <span class="n">kpoints</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
        <span class="n">plot_points</span><span class="p">(</span><span class="n">kpoints</span><span class="p">,</span> <span class="n">bz_lattice</span><span class="p">,</span>
                    <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="n">coords_are_cartesian</span><span class="p">,</span>
                    <span class="n">ax</span><span class="o">=</span><span class="n">ax</span><span class="p">,</span> <span class="n">fold</span><span class="o">=</span><span class="n">fold</span><span class="p">)</span>

    <span class="n">ax</span><span class="o">.</span><span class="n">set_xlim3d</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
    <span class="n">ax</span><span class="o">.</span><span class="n">set_ylim3d</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
    <span class="n">ax</span><span class="o">.</span><span class="n">set_zlim3d</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>

    <span class="c1"># ax.set_aspect(&#39;equal&#39;)</span>
    <span class="n">ax</span><span class="o">.</span><span class="n">axis</span><span class="p">(</span><span class="s2">&quot;off&quot;</span><span class="p">)</span>

    <span class="k">return</span> <span class="n">fig</span></div>


<div class="viewcode-block" id="plot_ellipsoid"><a class="viewcode-back" href="../../../pymatgen.electronic_structure.plotter.html#pymatgen.electronic_structure.plotter.plot_ellipsoid">[docs]</a><span class="k">def</span> <span class="nf">plot_ellipsoid</span><span class="p">(</span><span class="n">hessian</span><span class="p">,</span> <span class="n">center</span><span class="p">,</span> <span class="n">lattice</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">rescale</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">ax</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                   <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">arrows</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Plots a 3D ellipsoid rappresenting the Hessian matrix in input.</span>
<span class="sd">    Useful to get a graphical visualization of the effective mass</span>
<span class="sd">    of a band in a single k-point.</span>

<span class="sd">    Args:</span>
<span class="sd">        hessian: the Hessian matrix</span>
<span class="sd">        center: the center of the ellipsoid in reciprocal coords (Default)</span>
<span class="sd">        lattice: Lattice object of the Brillouin zone</span>
<span class="sd">        rescale: factor for size scaling of the ellipsoid</span>
<span class="sd">        ax: matplotlib :class:`Axes` or None if a new figure should be created.</span>
<span class="sd">        coords_are_cartesian: Set to True if you are providing a center in</span>
<span class="sd">                              cartesian coordinates. Defaults to False.</span>
<span class="sd">        kwargs: kwargs passed to the matplotlib function &#39;plot_wireframe&#39;.</span>
<span class="sd">                Color defaults to blue, rstride and cstride</span>
<span class="sd">                default to 4, alpha defaults to 0.2.</span>
<span class="sd">    Returns:</span>
<span class="sd">        matplotlib figure and matplotlib ax</span>
<span class="sd">    Example of use:</span>
<span class="sd">        fig,ax=plot_wigner_seitz(struct.reciprocal_lattice)</span>
<span class="sd">        plot_ellipsoid(hessian,[0.0,0.0,0.0], struct.reciprocal_lattice,ax=ax)</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">if</span> <span class="p">(</span><span class="ow">not</span> <span class="n">coords_are_cartesian</span><span class="p">)</span> <span class="ow">and</span> <span class="n">lattice</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
            <span class="s2">&quot;coords_are_cartesian False or fold True require the lattice&quot;</span><span class="p">)</span>

    <span class="k">if</span> <span class="ow">not</span> <span class="n">coords_are_cartesian</span><span class="p">:</span>
        <span class="n">center</span> <span class="o">=</span> <span class="n">lattice</span><span class="o">.</span><span class="n">get_cartesian_coords</span><span class="p">(</span><span class="n">center</span><span class="p">)</span>

    <span class="k">if</span> <span class="s2">&quot;color&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;color&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;b&quot;</span>
    <span class="k">if</span> <span class="s2">&quot;rstride&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;rstride&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">4</span>
    <span class="k">if</span> <span class="s2">&quot;cstride&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;cstride&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">4</span>
    <span class="k">if</span> <span class="s2">&quot;alpha&quot;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
        <span class="n">kwargs</span><span class="p">[</span><span class="s2">&quot;alpha&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.2</span>

    <span class="c1"># calculate the ellipsoid</span>
    <span class="c1"># find the rotation matrix and radii of the axes</span>
    <span class="n">U</span><span class="p">,</span> <span class="n">s</span><span class="p">,</span> <span class="n">rotation</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">svd</span><span class="p">(</span><span class="n">hessian</span><span class="p">)</span>
    <span class="n">radii</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>

    <span class="c1"># from polar coordinates</span>
    <span class="n">u</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="mf">2.0</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>
    <span class="n">v</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>
    <span class="n">x</span> <span class="o">=</span> <span class="n">radii</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">outer</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">cos</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
    <span class="n">y</span> <span class="o">=</span> <span class="n">radii</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">outer</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
    <span class="n">z</span> <span class="o">=</span> <span class="n">radii</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">outer</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ones_like</span><span class="p">(</span><span class="n">u</span><span class="p">),</span> <span class="n">np</span><span class="o">.</span><span class="n">cos</span><span class="p">(</span><span class="n">v</span><span class="p">))</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)):</span>
        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)):</span>
            <span class="p">[</span><span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">],</span> <span class="n">z</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">dot</span><span class="p">([</span><span class="n">x</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">],</span> <span class="n">z</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">]],</span>
                                                 <span class="n">rotation</span><span class="p">)</span> <span class="o">*</span> <span class="n">rescale</span> <span class="o">+</span> <span class="n">center</span>

    <span class="c1"># add the ellipsoid to the current axes</span>
    <span class="n">ax</span><span class="p">,</span> <span class="n">fig</span><span class="p">,</span> <span class="n">plt</span> <span class="o">=</span> <span class="n">get_ax3d_fig_plt</span><span class="p">(</span><span class="n">ax</span><span class="p">)</span>
    <span class="n">ax</span><span class="o">.</span><span class="n">plot_wireframe</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

    <span class="k">if</span> <span class="n">arrows</span><span class="p">:</span>
        <span class="n">color</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;b&#39;</span><span class="p">,</span> <span class="s1">&#39;g&#39;</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span>
        <span class="n">em</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
            <span class="n">em</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="p">:]</span> <span class="o">=</span> <span class="n">rotation</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="p">:]</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">rotation</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="p">:])</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
            <span class="n">ax</span><span class="o">.</span><span class="n">quiver3D</span><span class="p">(</span><span class="n">center</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">center</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">center</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">em</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">em</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span>
                        <span class="n">em</span><span class="p">[</span><span class="n">i</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="n">pivot</span><span class="o">=</span><span class="s1">&#39;tail&#39;</span><span class="p">,</span>
                        <span class="n">arrow_length_ratio</span><span class="o">=</span><span class="mf">0.2</span><span class="p">,</span> <span class="n">length</span><span class="o">=</span><span class="n">radii</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">*</span> <span class="n">rescale</span><span class="p">,</span>
                        <span class="n">color</span><span class="o">=</span><span class="n">color</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>

    <span class="k">return</span> <span class="n">fig</span><span class="p">,</span> <span class="n">ax</span></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.electronic_structure.plotter</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>